Module: ActiveAuthentication::Model::Lockable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_authentication/model/lockable.rb
Instance Method Summary collapse
- #increment_failed_attempts ⇒ Object
- #lock ⇒ Object
- #locked? ⇒ Boolean
- #send_unlock_instructions ⇒ Object
- #unlock ⇒ Object
Instance Method Details
#increment_failed_attempts ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/active_authentication/model/lockable.rb', line 14 def increment_failed_attempts increment :failed_attempts lock if failed_attempts == ActiveAuthentication.max_failed_attempts save end |
#lock ⇒ Object
26 27 28 29 30 |
# File 'lib/active_authentication/model/lockable.rb', line 26 def lock update locked_at: Time.now send_unlock_instructions end |
#locked? ⇒ Boolean
22 23 24 |
# File 'lib/active_authentication/model/lockable.rb', line 22 def locked? locked_at.present? end |
#send_unlock_instructions ⇒ Object
32 33 34 35 |
# File 'lib/active_authentication/model/lockable.rb', line 32 def send_unlock_instructions token = generate_token_for :unlock ActiveAuthentication::Mailer.with(token: token, user: self).unlock_instructions.deliver end |
#unlock ⇒ Object
37 38 39 |
# File 'lib/active_authentication/model/lockable.rb', line 37 def unlock update failed_attempts: 0, locked_at: nil end |