Closed yoshi1011 closed 1 year ago
You can configure global options in the Devise initializer:
Devise.setup do |config|
# ...
config.unlock_in = 1.hour
# ...
end
For individual models, you can pass most of the same options directly to the devise
call, e.g.:
class AdminUser < ApplicationRecord
devise :lockable, ...etc, unlock_in: 15.minutes
end
class User < ApplicationRecord
devise :lockable, ...etc, unlock_in: 1.hour
end
Here's one example from the test suite that configures a couple other options: https://github.com/heartcombo/devise/blob/232c855c54cc3e471afbd48b6eda8ff164638c09/test/rails_app/lib/shared_user.rb#L7-L10
Those override the default config on a per-model basis, and only apply to that model. I hope that helps.
We are currently using Devise to generate a User model for AdminUser, the administrator user, and a User model for the general user.
And we are adding Lockable's module to both of them.
I would like to separate the time settings for unlock_in in config/initializers/devise.rb, 1.hours for AdminUser and 15.minutes for User.
I have considered using warden's default_strategies, but I don't think it would be effective because warden does not have a lockable mechanism...