app/controllers/openstax/accounts/sessions_controller.rb in openstax_accounts-1.0.0 vs app/controllers/openstax/accounts/sessions_controller.rb in openstax_accounts-2.0.0

- old
+ new

@@ -1,40 +1,52 @@ module OpenStax module Accounts class SessionsController < OpenStax::Accounts::ApplicationController def new - session[:return_to] ||= request.referrer - redirect_to RouteHelper.get_path(:login) + if OpenStax::Accounts.configuration.enable_stubbing? + with_interceptor { redirect_to dev_accounts_path } + else + redirect_to openstax_login_path + end end - def omniauth_authenticated - handle_with(SessionsOmniauthAuthenticated, - success: lambda { - sign_in(@handler_result.outputs[:accounts_user_to_sign_in]) - # referrer is in Accounts, so don't include it - redirect_to return_url - }, - failure: lambda { - failure - }) + 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 - redirect_to OpenStax::Accounts.configuration.enable_stubbing? ? - return_url : - OpenStax::Utilities.generate_url( - OpenStax::Accounts.configuration.openstax_accounts_url + "/logout", - return_to: return_url - ) + 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_to return_url, alert: "Authentication failed, please try again." + redirect_back alert: "Authentication failed, please try again." end end end end