Module: Headstart::User::InstanceMethods
- Defined in:
- lib/headstart/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?.
-
#confirm_email! ⇒ Object
Confirm my email.
- #facebook_user? ⇒ Boolean
-
#forgot_password! ⇒ Object
Mark my account as forgotten password.
- #last_name_should_be_required? ⇒ Boolean
-
#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.
-
#suppress_receive_welcome_email? ⇒ Boolean
Don’t send welcome email if email already confirmed, or use is a facebook connect user.
-
#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.
168 169 170 |
# File 'lib/headstart/user.rb', line 168 def admin? self.role == Admin end |
#authenticated?(password) ⇒ true, false
Am I authenticated with given password?
93 94 95 |
# File 'lib/headstart/user.rb', line 93 def authenticated?(password) encrypted_password == encrypt(password) end |
#confirm_email! ⇒ Object
Confirm my email.
131 132 133 134 135 |
# File 'lib/headstart/user.rb', line 131 def confirm_email! self.email_confirmed = true self.confirmation_token = nil save(false) end |
#facebook_user? ⇒ Boolean
161 162 163 |
# File 'lib/headstart/user.rb', line 161 def facebook_user? !self.facebook_uid.blank? end |
#forgot_password! ⇒ Object
Mark my account as forgotten password.
141 142 143 144 |
# File 'lib/headstart/user.rb', line 141 def forgot_password! generate_password_reset_token save(false) end |
#last_name_should_be_required? ⇒ Boolean
83 84 85 |
# File 'lib/headstart/user.rb', line 83 def last_name_should_be_required? true end |
#name ⇒ Object
Returns the user’s full name.
175 176 177 |
# File 'lib/headstart/user.rb', line 175 def name "#{self.first_name} #{self.last_name}" end |
#remember_me! ⇒ Object
Deprecated.
Use #reset_remember_token! instead
Set the remember token.
113 114 115 116 |
# File 'lib/headstart/user.rb', line 113 def remember_me! warn "[DEPRECATION] remember_me!: use reset_remember_token! instead" reset_remember_token! end |
#reset_remember_token! ⇒ Object
Reset the remember token.
122 123 124 125 |
# File 'lib/headstart/user.rb', line 122 def reset_remember_token! generate_remember_token save(false) end |
#suppress_receive_welcome_email? ⇒ Boolean
Don’t send welcome email if email already confirmed, or use is a facebook connect user
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/headstart/user.rb', line 99 def suppress_receive_welcome_email? return true if email_confirmed? if self.facebook_uid.present? self.email_confirmed = true self.confirmation_token = nil self.save return true end return false end |
#update_password(new_password, new_password_confirmation) ⇒ true, false
Update my password.
152 153 154 155 156 157 158 159 |
# File 'lib/headstart/user.rb', line 152 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 |