Diego
Diego

Reputation: 37

Devise log in with one more condition to check

I´m using devise gem in a rails 4 app and I have in my user table a column called valid that by default is false, when the user registers in the site it should send me a email with the information about them and approve it, and put that valid column in true. So then in the log in action it will check that valid is true and let them login to the site. My question is how modify that login action that takes care of the valid column in users table.

Upvotes: 2

Views: 1722

Answers (1)

Nick Veys
Nick Veys

Reputation: 23939

You should look at adding :confirmable to your User model, it may take care of most of what you are looking to do.

Otherwise, if you want to modify whether someone can login, look at the wiki on how to customize account validation.

From the wiki:

def active_for_authentication?
  # Uncomment the below debug statement to view the properties of the returned 
  # self model values.
  # logger.debug self.to_yaml

  super && account_active?
end

Upvotes: 3

Related Questions