Module: BlueLightSpecial::User::InstanceMethods
- Defined in:
- lib/blue_light_special/user.rb
Instance Method Summary collapse
-
#admin? ⇒ Boolean
Returns
true
if the user is an admin. -
#authenticated?(password) ⇒ true, false
Am I authenticated with given password?.
- #facebook_user? ⇒ Boolean
-
#forgot_password! ⇒ Object
Mark my account as forgotten password.
-
#name ⇒ Object
Returns the user’s full name.
-
#remember_me! ⇒ Object
deprecated
Deprecated.
Use #reset_remember_token! instead
-
#reset_remember_token! ⇒ Object
Reset the remember token.
-
#update_password(new_password, new_password_confirmation) ⇒ true, false
Update my password.
Instance Method Details
#admin? ⇒ Boolean
Returns true
if the user is an admin.
139 140 141 |
# File 'lib/blue_light_special/user.rb', line 139 def admin? self.role == Admin end |
#authenticated?(password) ⇒ true, false
Am I authenticated with given password?
87 88 89 |
# File 'lib/blue_light_special/user.rb', line 87 def authenticated?(password) encrypted_password == encrypt(password) end |
#facebook_user? ⇒ Boolean
132 133 134 |
# File 'lib/blue_light_special/user.rb', line 132 def facebook_user? !self.facebook_uid.blank? end |
#forgot_password! ⇒ Object
Mark my account as forgotten password.
112 113 114 115 |
# File 'lib/blue_light_special/user.rb', line 112 def forgot_password! generate_password_reset_token save(false) end |
#name ⇒ Object
Returns the user’s full name.
146 147 148 |
# File 'lib/blue_light_special/user.rb', line 146 def name "#{self.first_name} #{self.last_name}" end |
#remember_me! ⇒ Object
Deprecated.
Use #reset_remember_token! instead
Set the remember token.
94 95 96 97 |
# File 'lib/blue_light_special/user.rb', line 94 def remember_me! warn "[DEPRECATION] remember_me!: use reset_remember_token! instead" reset_remember_token! end |
#reset_remember_token! ⇒ Object
Reset the remember token.
103 104 105 106 |
# File 'lib/blue_light_special/user.rb', line 103 def reset_remember_token! generate_remember_token save(false) end |
#update_password(new_password, new_password_confirmation) ⇒ true, false
Update my password.
123 124 125 126 127 128 129 130 |
# File 'lib/blue_light_special/user.rb', line 123 def update_password(new_password, new_password_confirmation) self.password = new_password self.password_confirmation = new_password_confirmation if valid? self.password_reset_token = nil end save end |