please how and where can i place additional authentication logic in devise?
i have added a custom column called expire_date in my users table and it is a date column.
i want开发者_如何学运维 an additional requirement that the date there must not be later than todays date before allowing them to be authenticated.
please where can i add this logic?
thanks
Or you can override the active_for_authentication
? method in your User model
def active_for_authentication?
super && (test your dates here)
end
If it is inactive, it will generate a flash message about the account not being active. If you want something different like "This user is not active yet", change the setting for :inactive
in the file config/locales/devise.en.yml
. This is taken mostly from the Devise wiki.
Create your own controller that inherits from Devise::SessionsController
app / controllers / users /sessions_controller.rb
class Users::SessionsController < Devise::SessionsController
...
Overwrite the new method
...
Change what else you need to change
...
end
Add a new route to the routes file, and you are good to go.
精彩评论