Additional logic in authentication development

please, how and where can I place additional authentication logic in development?

I added a custom column called expire_date to my users table, and this is a date column.

I need an additional requirement that the date should not be lower than the date indicated before the date before allowing them to authenticate.

please where can i add this logic?

thanks

+4
source share
2 answers

Or can you override active_for_authentication ? method in your user model

 def active_for_authentication? super && (test your dates here) end 

If it is inactive, it generates a flash message stating that the account is inactive. If you want something else, for example, "This user has not been activated yet," change the :inactive parameter in the config/locales/devise.en.yml . This is taken mainly from the Develop wiki .

+3
source

Build your own controller that inherits from Devise :: SessionsController

application / 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 will be fine.

+1
source

All Articles