Sha256: 447a7b9c6ed435aefd72f27909c8d16fb807972aa0f9e0001cff56ce42eb8fa9

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

class UcbRails::SessionsController < ApplicationController
  
  skip_before_filter :ensure_authenticated_user

  def new
    provider = params.fetch(:provider, :cas)
    redirect_to "/auth/#{provider}"
  end

  def create
    session[:uid] = request.env['omniauth.auth'].uid
    session[:provider] = request.env['omniauth.auth'].provider
    # UserSessionManager.login(session[:uid])
    redirect_to session[:original_url] || root_path
  end
   
  def destroy
    # UserSessionManager.logout(current_user)
    provider = session[:provider]
    reset_session
    redirect_to redirect_url(provider)
  end
  
  def failure
    Rails.logger.debug("Authentication Failed for: #{request.env['omniauth.auth']}")
    render(:text => "Not Authorized", :status => 401)
  end
  
  private
  
  def redirect_url(provider)
    if provider.to_s == 'cas'
      "http://auth.berkeley.edu/cas/logout?url=#{root_url}"
    else
      root_path
    end
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ucb_rails-0.0.1 app/controllers/ucb_rails/sessions_controller.rb