Module: Workarea::User::Login
- Extended by:
- ActiveSupport::Concern
- Included in:
- Workarea::User
- Defined in:
- app/models/workarea/user/login.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #login_failure! ⇒ Object
- #login_locked? ⇒ Boolean
- #login_success! ⇒ Object
- #unlock_login! ⇒ Object
- #update_login!(request) ⇒ Object
- #valid_logged_in_request?(request) ⇒ Boolean
Instance Method Details
#login_failure! ⇒ Object
43 44 45 46 |
# File 'app/models/workarea/user/login.rb', line 43 def login_failure! self.failed_login_count += 1 mark_login_attempt end |
#login_locked? ⇒ Boolean
48 49 50 51 |
# File 'app/models/workarea/user/login.rb', line 48 def login_locked? exceeded_login_failure_limit? && last_login_attempt_at >= Workarea.config.lockout_period.ago end |
#login_success! ⇒ Object
37 38 39 40 41 |
# File 'app/models/workarea/user/login.rb', line 37 def login_success! self.last_login_at = Time.current self.failed_login_count = 0 mark_login_attempt end |
#unlock_login! ⇒ Object
53 54 55 |
# File 'app/models/workarea/user/login.rb', line 53 def unlock_login! update!(failed_login_count: 0) end |
#update_login!(request) ⇒ Object
57 58 59 60 61 62 |
# File 'app/models/workarea/user/login.rb', line 57 def update_login!(request) update_attributes!( ip_address: request.ip, user_agent: request.user_agent ) end |
#valid_logged_in_request?(request) ⇒ Boolean
64 65 66 67 |
# File 'app/models/workarea/user/login.rb', line 64 def valid_logged_in_request?(request) (ip_address.blank? || ip_address == request.ip) && (user_agent.blank? || user_agent == request.user_agent) end |