Class: KnockOnce::Password

Inherits:
Object
  • Object
show all
Defined in:
app/models/knock_once/password.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'app/models/knock_once/password.rb', line 4

def token
  @token
end

#userObject

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_resetObject



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_expiryObject



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