mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 04:03:45 +08:00
Init user session for devise controllers after token auth [SCI-5123]
This commit is contained in:
parent
5f70984919
commit
00a2f5f41b
1 changed files with 6 additions and 1 deletions
|
@ -22,7 +22,10 @@ module TokenAuthentication
|
|||
|
||||
Extends::API_PLUGABLE_AUTH_METHODS.each do |auth_method|
|
||||
method(auth_method).call
|
||||
return true if current_user
|
||||
if current_user
|
||||
sign_in(current_user) if devise_controller?
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
# Default token implementation
|
||||
|
@ -33,5 +36,7 @@ module TokenAuthentication
|
|||
payload = Api::CoreJwt.decode(@token)
|
||||
@current_user = User.find_by(id: payload['sub'])
|
||||
raise JWT::InvalidPayload, I18n.t('api.core.no_user_mapping') unless current_user
|
||||
|
||||
sign_in(current_user) if devise_controller?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue