Sha256: 9a1da67cf94f90c204b6ab24953cac055d01c4ac0a1faca0008ab1381923c643

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

module OpenStax
  module Accounts
    class SessionsController < OpenStax::Accounts::ApplicationController

      def new
        if OpenStax::Accounts.configuration.enable_stubbing?
          with_interceptor { redirect_to dev_accounts_path }
        else
          redirect_to openstax_login_path
        end
      end

      def callback
        handle_with(
          SessionsCallback,
            success: lambda {
              sign_in(@handler_result.outputs[:account])
              redirect_back
            },
            failure: lambda {
              failure
            })
      end

      def destroy
        sign_out!

        # If we're using the Accounts server, need to sign out of it so can't 
        # log back in automagically
        if OpenStax::Accounts.configuration.enable_stubbing?
          redirect_back
        else
          without_interceptor do

            redirect_to(
              OpenStax::Utilities.generate_url(
                OpenStax::Accounts.configuration.openstax_accounts_url,
                "logout",
                return_to: intercepted_url
              )
            )

          end
        end
      end

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

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openstax_accounts-4.0.0 app/controllers/openstax/accounts/sessions_controller.rb
openstax_accounts-3.1.1 app/controllers/openstax/accounts/sessions_controller.rb
openstax_accounts-3.1.0 app/controllers/openstax/accounts/sessions_controller.rb
openstax_accounts-3.0.0 app/controllers/openstax/accounts/sessions_controller.rb
openstax_accounts-2.0.0 app/controllers/openstax/accounts/sessions_controller.rb