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

Instance Method Details

#createnil

Login user after authentication by provider

Returns:

  • (nil)


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.(uid)
    session[:uid] = uid
    redirect_to session[:original_url] || root_path
  else
    redirect_to not_authorized_path
  end
end

#destroynil

Log user out

Returns:

  • (nil)


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

#failurenil

Handler for authentication failure.

Returns:

  • (nil)


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

#newnil

Redirects to authentication provider

Returns:

  • (nil)


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_authorizednil

Action called when unauthorized access attempted

Returns:

  • (nil)


44
45
46
# File 'app/controllers/ucb_rails_user/concerns/sessions_controller.rb', line 44

def not_authorized
  render(:text => "Not Authorized", :status => 401)
end