Class: OpenStax::Accounts::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OpenStax::Accounts::SessionsController
- Defined in:
- app/controllers/openstax/accounts/sessions_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#callback ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 18 def callback handle_with( SessionsCallback, success: -> do sign_in(@handler_result.outputs[:account]) redirect_back key: :accounts_return_to, strategies: [:session] end, failure: -> { failure } ) end |
#destroy ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 29 def destroy # if a handler is configured, let it handle everything if configuration.logout_handler configuration.logout_handler.call(self) else # Unless we are stubbing, we redirect to a configurable URL, which is normally # (or at least eventually) the Accounts logout URL so that users can't sign back # in automagically. sign_out! redirect_to(configuration.enable_stubbing? ? main_app.root_url : configuration.logout_redirect_url(request), allow_other_host: true) end end |
#failure ⇒ Object
44 45 46 |
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 44 def failure redirect_back key: :accounts_return_to, alert: 'Authentication failed, please try again.' end |
#new ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 4 def new if configuration.is_return_to_url_approved?(params[:return_to]) store_url url: params[:return_to], key: :accounts_return_to, strategies: [:session] end store_fallback key: :accounts_return_to, strategies: [:session] if configuration.enable_stubbing? redirect_to dev_accounts_path else forwardable_params = params.permit(*configuration.forwardable_login_params).to_h redirect_to openstax_login_path(forwardable_params) end end |
#profile ⇒ Object
48 49 50 51 |
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 48 def profile # TODO: stub profile if stubbing is enabled redirect_to URI.join(configuration.openstax_accounts_url, 'profile').to_s end |