Class: KnockOnce::Password
- Inherits:
-
Object
- Object
- KnockOnce::Password
- Defined in:
- app/models/knock_once/password.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #email_reset ⇒ Object
-
#initialize(user) ⇒ Password
constructor
A new instance of Password.
- #save_token_and_expiry ⇒ Object
Constructor Details
#initialize(user) ⇒ Password
Returns a new instance of Password.
6 7 8 9 |
# File 'app/models/knock_once/password.rb', line 6 def initialize(user) @token = SecureRandom.urlsafe_base64(KnockOnce.configuration.reset_token_length, false) @user = user end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'app/models/knock_once/password.rb', line 4 def token @token end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'app/models/knock_once/password.rb', line 4 def user @user end |
Instance Method Details
#email_reset ⇒ Object
16 17 18 |
# File 'app/models/knock_once/password.rb', line 16 def email_reset PasswordResetMailer.password_reset(@user, @token).deliver_now end |
#save_token_and_expiry ⇒ Object
11 12 13 14 |
# File 'app/models/knock_once/password.rb', line 11 def save_token_and_expiry User.find_by_email(@user['email']) .update_attributes(password_reset_token: @token, password_token_expiry: KnockOnce.configuration.password_token_expiry) end |