Class: CognitoIdpRails::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CognitoIdpRails::SessionsController
- Defined in:
- app/controllers/cognito_idp_rails/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#login ⇒ Object
7 8 9 |
# File 'app/controllers/cognito_idp_rails/sessions_controller.rb', line 7 def login redirect_to , allow_other_host: true end |
#login_callback ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/cognito_idp_rails/sessions_controller.rb', line 11 def login_callback client.get_token(grant_type: :authorization_code, code: params[:code], redirect_uri: auth_login_callback_url) do |token| client.get_user_info(token) do |user_info| reset_session configuration.after_login.call(token, user_info, request) redirect_to configuration.after_login_route, notice: "You have been successfully logged in." return end end redirect_to configuration.after_login_route, notice: "Login failed." end |
#logout ⇒ Object
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_callback ⇒ Object
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 |