Module: Sorcery::Model::Submodules::BruteForceProtection::InstanceMethods
- Defined in:
- lib/sorcery/model/submodules/brute_force_protection.rb
Instance Method Summary collapse
- #login_locked? ⇒ Boolean
-
#login_unlock! ⇒ Object
/!\ Moved out of protected for use like activate! in controller /!.
-
#register_failed_login! ⇒ Object
Called by the controller to increment the failed logins counter.
Instance Method Details
#login_locked? ⇒ Boolean
88 89 90 |
# File 'lib/sorcery/model/submodules/brute_force_protection.rb', line 88 def login_locked? !login_unlocked? end |
#login_unlock! ⇒ Object
/!\ Moved out of protected for use like activate! in controller /!\
80 81 82 83 84 85 86 |
# File 'lib/sorcery/model/submodules/brute_force_protection.rb', line 80 def login_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 } sorcery_adapter.update_attributes(attributes) end |
#register_failed_login! ⇒ Object
Called by the controller to increment the failed logins counter. Calls ‘login_lock!’ if login retries limit was reached.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sorcery/model/submodules/brute_force_protection.rb', line 66 def register_failed_login! config = sorcery_config return unless login_unlocked? sorcery_adapter.increment(config.failed_logins_count_attribute_name) return unless send(config.failed_logins_count_attribute_name) >= config.consecutive_login_retries_amount_limit login_lock! end |