Inline now anemic helper methods
This commit is contained in:
committed by
Stanko K.R.
parent
3329008dd8
commit
467843fe22
@@ -56,8 +56,10 @@ module Authentication
|
||||
end
|
||||
|
||||
def authenticate_by_bearer_token
|
||||
if request_authorized_by_bearer_token?
|
||||
if access_token = Identity::AccessToken.find_by(token: authorization_bearer_token)
|
||||
scheme, bearer_token = request.authorization.to_s.split(" ", 2)
|
||||
|
||||
if scheme == "Bearer" && bearer_token.present?
|
||||
if access_token = Identity::AccessToken.find_by(token: bearer_token)
|
||||
Current.identity = access_token.identity
|
||||
else
|
||||
head :unauthorized
|
||||
@@ -65,14 +67,6 @@ module Authentication
|
||||
end
|
||||
end
|
||||
|
||||
def request_authorized_by_bearer_token?
|
||||
request.authorization.to_s.starts_with? "Bearer"
|
||||
end
|
||||
|
||||
def authorization_bearer_token
|
||||
request.authorization.to_s.split(" ", 2).second
|
||||
end
|
||||
|
||||
def request_authentication
|
||||
if Current.account.present?
|
||||
session[:return_to_after_authenticating] = request.url
|
||||
|
||||
Reference in New Issue
Block a user