this is my sessions controller code
def respond_to_on_destroy
jwt_payload = JWT.decode(request.headers['Authorization'].split(' ')[1],
Rails.application.credentials.fetch(:secret_key_base)).first
current_user = User.find(jwt_payload['sub'])
if current_user
debugger
return render json: {
status: 200, message: 'signed out successfully'
}
else
return render json: {
status: 401, message: 'user has no active session'
}
end
end
this is my devise.rb file code
config.jwt do |jwt|
jwt.secret = Rails.application.credentials.fetch(:secret_key_base)
jwt.dispatch_requests = [
['POST', %r{^/users/sign_in$}]
]
jwt.revocation_requests = [
['DELETE', %r{^/users/sign_out}]
]
jwt.expiration_time = 120.minutes.to_i
end
i am devise and devise-jwt and i am using rails 7 version
Try insert in your Gemfile:
gem 'warden-jwt_auth', '~> 0.6.0'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.