mirror of
https://github.com/docusealco/docuseal
synced 2026-11-05 06:42:32 -05:00
do not use devise strategy for api auth
This commit is contained in:
1 parent
64c8707957
commit
94a13ffca2
3 files changed
+12
-24
No files matched your search
@@ -1,19 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AuthWithTokenStrategy < Devise::Strategies::Base
|
||||
def valid?
|
||||
request.headers['X-Auth-Token'].present?
|
||||
end
|
||||
|
||||
def authenticate!
|
||||
sha256 = Digest::SHA256.hexdigest(request.headers['X-Auth-Token'])
|
||||
|
||||
user = User.joins(:access_token).find_by(access_token: { sha256: })
|
||||
|
||||
if user
|
||||
success!(user)
|
||||
else
|
||||
fail!('Invalid token')
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user