sessions: fixup bugs in b2cf765d6.
Deal with the cases where either the `login` param is given without the `api_key`, or the `api_key` is given with the `login`.
This commit is contained in:
@@ -57,6 +57,8 @@ class SessionLoader
|
|||||||
authenticate_basic_auth
|
authenticate_basic_auth
|
||||||
elsif params[:login].present? && params[:api_key].present?
|
elsif params[:login].present? && params[:api_key].present?
|
||||||
authenticate_api_key(params[:login], params[:api_key])
|
authenticate_api_key(params[:login], params[:api_key])
|
||||||
|
else
|
||||||
|
raise AuthenticationFailure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -68,8 +70,9 @@ class SessionLoader
|
|||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_api_key(name, api_key)
|
def authenticate_api_key(name, api_key)
|
||||||
CurrentUser.user = User.find_by_name(name)&.authenticate_api_key(api_key)
|
user = User.find_by_name(name)&.authenticate_api_key(api_key)
|
||||||
raise AuthenticationFailure unless Currentuser.user.present?
|
raise AuthenticationFailure if user.blank?
|
||||||
|
CurrentUser.user = user
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_param_user(signed_user_id)
|
def load_param_user(signed_user_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user