Module: Sorcery::Model::Submodules::BruteForceProtection::InstanceMethods
- Defined in:
- lib/sorcery/model/submodules/brute_force_protection.rb
Instance Method Summary collapse
-
#register_failed_login! ⇒ Object
Called by the controller to increment the failed logins counter.
-
#unlock! ⇒ Object
/!\ Moved out of protected for use like activate! in controller /!.
Instance Method Details
#register_failed_login! ⇒ Object
Called by the controller to increment the failed logins counter. Calls ‘lock!’ if login retries limit was reached.
71 72 73 74 75 76 77 |
# File 'lib/sorcery/model/submodules/brute_force_protection.rb', line 71 def register_failed_login! config = sorcery_config return if !unlocked? self.increment(config.failed_logins_count_attribute_name) self.update_many_attributes(config.failed_logins_count_attribute_name => self.send(config.failed_logins_count_attribute_name)) self.lock! if self.send(config.failed_logins_count_attribute_name) >= config.consecutive_login_retries_amount_limit end |
#unlock! ⇒ Object
/!\ Moved out of protected for use like activate! in controller /!\
82 83 84 85 86 87 88 |
# File 'lib/sorcery/model/submodules/brute_force_protection.rb', line 82 def unlock! config = sorcery_config attributes = {config.lock_expires_at_attribute_name => nil, config.failed_logins_count_attribute_name => 0, config.unlock_token_attribute_name => nil} self.update_many_attributes(attributes) end |