Module: UcbRailsUser::Concerns::SessionsController
- Extended by:
- ActiveSupport::Concern
- Included in:
- SessionsController
- Defined in:
- app/controllers/ucb_rails_user/concerns/sessions_controller.rb
Instance Method Summary collapse
-
#create ⇒ nil
Login user after authentication by provider.
-
#destroy ⇒ nil
Log user out.
-
#failure ⇒ nil
Handler for authentication failure.
-
#new ⇒ nil
Redirects to authentication provider.
-
#not_authorized ⇒ nil
Action called when unauthorized access attempted.
Instance Method Details
#create ⇒ nil
Login user after authentication by provider
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/ucb_rails_user/concerns/sessions_controller.rb', line 19 def create uid = request.env['omniauth.auth'].uid session[:omniauth_provider] = request.env['omniauth.auth'].provider if user_session_manager.login(uid) session[:uid] = uid redirect_to session[:original_url] || root_path else redirect_to end end |
#destroy ⇒ nil
Log user out
34 35 36 37 38 39 |
# File 'app/controllers/ucb_rails_user/concerns/sessions_controller.rb', line 34 def destroy user_session_manager.logout(current_user) provider = session[:omniauth_provider] reset_session redirect_to redirect_url(provider) end |
#failure ⇒ nil
Handler for authentication failure.
51 52 53 54 |
# File 'app/controllers/ucb_rails_user/concerns/sessions_controller.rb', line 51 def failure Rails.logger.debug("Authentication Failed for: #{request.env['omniauth.auth']}") render(:text => "Not Authorized", :status => 401) end |
#new ⇒ nil
Redirects to authentication provider
11 12 13 14 |
# File 'app/controllers/ucb_rails_user/concerns/sessions_controller.rb', line 11 def new provider = UcbRailsUser[:omniauth_provider] || :cas redirect_to "/auth/#{provider}" end |
#not_authorized ⇒ nil
Action called when unauthorized access attempted
44 45 46 |
# File 'app/controllers/ucb_rails_user/concerns/sessions_controller.rb', line 44 def render(:text => "Not Authorized", :status => 401) end |