knock
knock copied to clipboard
Track successful and not successful login & disabled users
I would like to write some informations to the database like:
- last successful login date
- last unsuccessful login attempt
- number of unsuccessful login attempt
What is the best way to achieve this?
And second I would like to mark users as disabled in the database and throw an exception on login.
You could overwrite the User#authenticate method (which is what I’m currently doing):
class User
def authenticate(password)
return false if locked?
user = super(password)
failed_auth_attempt! unless user
user
end
end