Sha256: 509dd86af786700419a3c6407b867237606b53fe45b09a1b3d3d5fb15113bfe5
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
class SwitchUserController < ApplicationController before_action :developer_modes_only def set_current_user handle_request(params) redirect_to(SwitchUser.redirect_path.call(request, params)) end def remember_user # NOOP unless the user has explicity enabled this feature if SwitchUser.switch_back provider.remember_current_user(params[:remember] == "true") end redirect_to(SwitchUser.redirect_path.call(request, params)) end private def developer_modes_only raise ActionController::RoutingError.new('Do not try to hack us.') unless available? end def available? SwitchUser.guard_class.new(self, provider).controller_available? end def handle_request(params) if params[:scope_identifier].blank? provider.logout_all else record = SwitchUser.data_sources.find_scope_id(params[:scope_identifier]) unless record provider.logout_all return end if SwitchUser.login_exclusive provider.login_exclusive(record.user, :scope => record.scope) else provider.login_inclusive(record.user, :scope => record.scope) end end end # TODO make helper methods, so this can be eliminated from the # SwitchUserHelper def provider SwitchUser::Provider.init(self) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
switch_user-1.4.0 | app/controllers/switch_user_controller.rb |
switch_user-1.3.1 | app/controllers/switch_user_controller.rb |
switch_user-1.3.0 | app/controllers/switch_user_controller.rb |