[英]ROR: devise-jwt : how to call jwt_revoked? function?
I am using devise and devise-jwt for my ror api.我正在为我的 ror api 使用 devise 和 devise-jwt。 I would like to let know the user (by api call) if the user bearer token sent is revoked or not.
如果发送的用户不记名令牌被撤销,我想知道用户(通过 api 调用)。
I made this route:我做了这条路线:
def user_token_revoked
decoder = JWT::Decode.new(
request.headers['Authorization'].split(' ')[1],
'GENERATED_TOKEN',
nil,
nil
)
decoded = decoder.decode_segments
user = User.find_by_id(decoded[0]['sub']) # get id user from decoded token
render json: user.jwt_revoked?(decoded), status: :ok
end
But it produces me this error: #<NoMethodError: undefined method `jwt_revoked?'但它给我带来了这个错误:#<NoMethodError: undefined method `jwt_revoked?' for #User:0x0000558992eb9b98>
对于#用户:0x0000558992eb9b98>
I am using this jwt_revocation_strategy: JwtBlacklist in my model:我在我的 model 中使用这个 jwt_revocation_strategy: JwtBlacklist:
class JwtBlacklist < ApplicationRecord
include Devise::JWT::RevocationStrategies::Denylist
self.table_name = 'jwt_blacklists'
end
How to call jwt_revoked?如何调用 jwt_revoked? function??
function??
Thanks谢谢
jwt_revoked?
is part of the Devise::JWT::RevocationStrategies::Denylist
module.是
Devise::JWT::RevocationStrategies::Denylist
模块的一部分。 So you'll need to call JwtBlacklist
model所以你需要调用
JwtBlacklist
model
JwtBlacklist.jwt_revoked?(decoded, user)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.