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

Instance Method Details

#login_failure!Object



43
44
45
46
# File 'app/models/workarea/user/login.rb', line 43

def 
  self. += 1
  
end

#login_locked?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'app/models/workarea/user/login.rb', line 48

def 
   &&
     >= Workarea.config.lockout_period.ago
end

#login_success!Object



37
38
39
40
41
# File 'app/models/workarea/user/login.rb', line 37

def 
  self. = Time.current
  self. = 0
  
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

Returns:

  • (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