knock icon indicating copy to clipboard operation
knock copied to clipboard

Track successful and not successful login & disabled users

Open christiangewalt opened this issue 7 years ago • 1 comments

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.

christiangewalt avatar May 10 '18 18:05 christiangewalt

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

rubiii avatar Aug 05 '18 18:08 rubiii