Class: CognitoIdpRails::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cognito_idp_rails/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#loginObject



7
8
9
# File 'app/controllers/cognito_idp_rails/sessions_controller.rb', line 7

def 
  redirect_to authorization_url, allow_other_host: true
end

#login_callbackObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/cognito_idp_rails/sessions_controller.rb', line 11

def 
  client.get_token(grant_type: :authorization_code, code: params[:code], redirect_uri: ) do |token|
    client.(token) do ||
      reset_session
      configuration..call(token, , request)
      redirect_to configuration., notice: "You have been successfully logged in."
      return
    end
  end
  redirect_to configuration., notice: "Login failed."
end

#logoutObject



23
24
25
# File 'app/controllers/cognito_idp_rails/sessions_controller.rb', line 23

def logout
  redirect_to client.logout_uri(logout_uri: auth_logout_callback_url), allow_other_host: true
end

#logout_callbackObject



27
28
29
30
31
# File 'app/controllers/cognito_idp_rails/sessions_controller.rb', line 27

def logout_callback
  configuration.before_logout.call(request)
  reset_session
  redirect_to configuration.after_logout_route, notice: "You have been successfully logged out."
end