Module: MinimalistAuthentication::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/minimalist_authentication/user.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#authenticated?(password) ⇒ Boolean
Returns true if password matches the hashed_password, otherwise returns false.
-
#enabled ⇒ Object
Called after a user is authenticated to determine if the user object should be returned.
-
#enabled? ⇒ Boolean
Returns true if the user is enabled.
-
#errors ⇒ Object
Remove the has_secure_password password blank error if user is inactive.
-
#guest? ⇒ Boolean
Deprecated method to check if the user is a guest.
-
#inactive? ⇒ Boolean
Returns true if the user is not active.
-
#logged_in ⇒ Object
Sets #last_logged_in_at to the current time without updating the updated_at timestamp.
Instance Method Details
#authenticated?(password) ⇒ Boolean
Returns true if password matches the hashed_password, otherwise returns false.
76 77 78 79 80 81 |
# File 'lib/minimalist_authentication/user.rb', line 76 def authenticated?(password) MinimalistAuthentication.deprecator.warn(<<-MSG.squish) Calling #authenticated? is deprecated. Use #authenticate instead. MSG authenticate(password) end |
#enabled ⇒ Object
Called after a user is authenticated to determine if the user object should be returned.
60 61 62 |
# File 'lib/minimalist_authentication/user.rb', line 60 def enabled self if enabled? end |
#enabled? ⇒ Boolean
Returns true if the user is enabled. Override this method in your user model to implement custom logic that determines if a user is eligible to log in.
66 67 68 |
# File 'lib/minimalist_authentication/user.rb', line 66 def enabled? active? end |
#errors ⇒ Object
Remove the has_secure_password password blank error if user is inactive.
71 72 73 |
# File 'lib/minimalist_authentication/user.rb', line 71 def errors super.tap { |errors| errors.delete(:password, :blank) if inactive? } end |
#guest? ⇒ Boolean
Deprecated method to check if the user is a guest. Returns false because the guest user has been removed.
84 85 86 87 88 89 90 91 |
# File 'lib/minimalist_authentication/user.rb', line 84 def guest? MinimalistAuthentication.deprecator.warn(<<-MSG.squish) Calling #guest? is deprecated. Use #MinimalistAuthentication::Controller#logged_in? to check for the presence of a current_user instead. MSG false end |
#inactive? ⇒ Boolean
Returns true if the user is not active.
94 95 96 |
# File 'lib/minimalist_authentication/user.rb', line 94 def inactive? !active? end |
#logged_in ⇒ Object
Sets #last_logged_in_at to the current time without updating the updated_at timestamp.
99 100 101 |
# File 'lib/minimalist_authentication/user.rb', line 99 def logged_in update_column(:last_logged_in_at, Time.current) end |