slight changes to application controller to be more readable
This commit is contained in:

committed by
Sebastian Serth

parent
c638df12e7
commit
cc3fc72cf9
@ -15,7 +15,11 @@ class ApplicationController < ActionController::Base
|
||||
rescue_from ActionController::InvalidAuthenticityToken, with: :render_csrf_error
|
||||
|
||||
def current_user
|
||||
@current_user ||= ExternalUser.find_by(id: session[:external_user_id]) || login_from_session || login_from_other_sources || nil
|
||||
@current_user ||= ExternalUser.find_by(id: session[:external_user_id]) ||
|
||||
login_from_session ||
|
||||
login_from_other_sources ||
|
||||
login_from_authentication_token ||
|
||||
nil
|
||||
end
|
||||
|
||||
def require_user!
|
||||
@ -32,6 +36,13 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def login_from_authentication_token
|
||||
token = AuthenticationToken.find_by(shared_secret: params[:token])
|
||||
return unless token
|
||||
|
||||
auto_login(token.user) if token.expire_at.future?
|
||||
end
|
||||
|
||||
def set_sentry_context
|
||||
return if current_user.blank?
|
||||
|
||||
|
Reference in New Issue
Block a user