Module: MinimalistAuthentication::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/minimalist_authentication/user.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- GUEST_USER_EMAIL =
'guest'
- PASSWORD_MIN =
8
- PASSWORD_MAX =
40
Instance Method Summary collapse
-
#active? ⇒ Boolean
Returns true if the user is active.
-
#authenticated?(password) ⇒ Boolean
Return true if password matches the hashed_password.
-
#inactive? ⇒ Boolean
Returns true if the user is not active.
-
#is_guest? ⇒ Boolean
Check if user is a guest based on their email attribute.
- #logged_in ⇒ Object
Instance Method Details
#active? ⇒ Boolean
Returns true if the user is active.
72 73 74 |
# File 'lib/minimalist_authentication/user.rb', line 72 def active? active end |
#authenticated?(password) ⇒ Boolean
Return true if password matches the hashed_password. If successful checks for an outdated password_hash and updates if necessary.
84 85 86 87 88 89 90 91 |
# File 'lib/minimalist_authentication/user.rb', line 84 def authenticated?(password) if password_object == password update_hash!(password) if password_object.stale? return true end return false end |
#inactive? ⇒ Boolean
Returns true if the user is not active.
77 78 79 |
# File 'lib/minimalist_authentication/user.rb', line 77 def inactive? !active end |
#is_guest? ⇒ Boolean
Check if user is a guest based on their email attribute
99 100 101 |
# File 'lib/minimalist_authentication/user.rb', line 99 def is_guest? email == GUEST_USER_EMAIL end |
#logged_in ⇒ Object
93 94 95 96 |
# File 'lib/minimalist_authentication/user.rb', line 93 def logged_in # use update_column to avoid updated_on trigger update_column(:last_logged_in_at, Time.current) end |