Mexa Fireg
Mexa Fireg

Reputation: 81

Implementing JWT on Rails

I am having a problem while trying to implement devise jwt. This is my devise user model:

class User < ApplicationRecord  
devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable,
         :database_authenticatable,
         :jwt_authenticatable,
         jwt_revocation_strategy: JwtBlacklist 
end

And this is my blacklist.rb model.

class JwtBlacklist < ApplicationRecord
include Devise::JWT::RevocationStrategies::Blacklist

self.table_name = 'jwt_blacklist'
end

This is what i am getting.

Caused by:
NameError: uninitialized constant User::JwtBlacklist

Hope you could help me with this I am new on Rails. Thank you so much.

Upvotes: 4

Views: 3408

Answers (2)

jdps
jdps

Reputation: 349

Note that include Devise::JWT::RevocationStrategies::Blacklist had been replaced with include Devise::JWT::RevocationStrategies::Denylist according to devise-jwt documentation.

Upvotes: 17

tadman
tadman

Reputation: 211540

If you're calling your model JwtBlacklist then the filename must be jwt_blacklist.rb so that the auto-loader can find it. Right now the name implies the model is called Blacklist.

Upvotes: 4

Related Questions