do not use devise strategy for api auth

This commit is contained in:
Pete Matsyburka
2023-12-26 01:19:28 +02:00
parent 64c8707957
commit 94a13ffca2
3 changed files with 12 additions and 24 deletions
@@ -33,6 +33,17 @@ module Api
result
end
def authenticate_user!
@current_user ||=
if request.headers['X-Auth-Token'].present?
sha256 = Digest::SHA256.hexdigest(request.headers['X-Auth-Token'])
User.joins(:access_token).find_by(access_token: { sha256: })
end
render json: { error: 'Not authenticated' }, status: :unauthorized unless current_user
end
def current_account
current_user&.account
end