Sha256: 2754a7e87a7357db2d604fbb56c1fb98b68530fe9634cff2e26fc15d9b77f85a
Contents?: true
Size: 1.57 KB
Versions: 4
Compression:
Stored size: 1.57 KB
Contents
require_dependency "openstax/connect/application_controller" module OpenStax module Connect class SessionsController < ApplicationController skip_before_filter :authenticate_user! def new redirect_to RouteHelper.get_path(:login) end def omniauth_authenticated handle_with(SessionsOmniauthAuthenticated, complete: lambda { sign_in(@handler_result.outputs[:connect_user_to_sign_in]) redirect_to return_url(true) }) end def destroy sign_out! # If we're using the Services server, need to sign out of it so can't # log back in automagically redirect_to OpenStax::Connect.configuration.enable_stubbing? ? return_url : OpenStax::Utilities.generate_url( OpenStax::Connect.configuration.openstax_services_url + "/logout", return_to: return_url ) end def failure redirect_to return_url, alert: "Authentication failed, please try again." end def become raise SecurityTransgression unless !Rails.env.production? || current_user.is_administrator? sign_in(User.find(params[:user_id])) redirect_to return_url(true) end protected def return_url(include_referrer=false) referrer = include_referrer ? request.referrer : nil params[:return_to] || session.delete(:return_to) || referrer || main_app.root_url end end end end
Version data entries
4 entries across 4 versions & 1 rubygems