Closed Amystherdam closed 1 year ago
Putting this in application_controller or graphql_controller if using graphql should work, assuming your GraphqlApiService file or whatever frontend file is sending the bearer token in the header of each request
def current_user
return unless request.headers['Authorization'].present?
token = request.headers['Authorization'].split(" ").last
warden.authenticate!(auth_token: token)
end
Expected behavior
That the current_user is filled with the logged in user
Actual behavior
When the user logs in and the request is going through one of Devise's default controllers, the current_user is populated, but when the user is already logged in, the current_user is lost and becomes null
Even in application_controller current_user is already null
Settings made
config/initializers/devise_jwt.rb
config/initializers/devise.rb
app/models/user.rb
JTI Migration
Debugging information
Provide following information. Please, format pasted output as code. Feel free to remove the secret key value.
devise-jwt
in use: 0.10.0rails
in use: 7.0.4warden-jwt_auth
in use: 0.7.0Devise::JWT.config
Warden::JWTAuth.config
Devise.mappings
Observation
I'm not using rack-cors, the app is a monolith