Home > Software engineering >  Rails - Devise gem - Add one more check during login
Rails - Devise gem - Add one more check during login

Time:04-07

I am using devise gem. I would like to add one more condition check while the user clicks in login button. So for I haven't customized create method in sessions controller.

I would like to add a condition like if user.valid? There is one field called valid in database. What is the best way to do this with devise

Any guidance or help would be appreciated

CodePudding user response:

Check this documentation, the main idea is to override active_for_authentication?.

class User < ActiveRecord::Base
  def active_for_authentication?
    super && special_condition_is_valid?
  end
end
  • Related