Class: OpenStax::Accounts::SessionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user

Instance Method Details

#destroyObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 22

def destroy
  sign_out!

  # If we're using the Accounts server, need to sign out of it so can't 
  # log back in automagically
  redirect_to OpenStax::Accounts.configuration.enable_stubbing? ?
                return_url :
                OpenStax::Utilities.generate_url(
                  OpenStax::Accounts.configuration.openstax_accounts_url + "/logout",
                  return_to: return_url
                )
end

#failureObject



35
36
37
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 35

def failure
  redirect_to return_url, alert: "Authentication failed, please try again."
end

#newObject



5
6
7
8
# File 'app/controllers/openstax/accounts/sessions_controller.rb', line 5

def new
  session[:return_to] ||= request.referrer
  redirect_to RouteHelper.get_path(:login)
end

#omniauth_authenticatedObject



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

def omniauth_authenticated
  handle_with(SessionsOmniauthAuthenticated,
              success: lambda {
                (@handler_result.outputs[:accounts_user_to_sign_in])
                # referrer is in Accounts, so don't include it
                redirect_to return_url
              },
              failure: lambda {
                failure
              })
end