Module: EasyAuth::Models::Identities::Password
- Extended by:
- ActiveSupport::Concern
- Includes:
- TokenGenerator
- Included in:
- Identities::Password
- Defined in:
- lib/easy_auth/models/identities/password.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #authenticate(unencrypted_token, token_name = :password) ⇒ Object
- #generate_reset_token! ⇒ Object
- #password=(unencrypted_password) ⇒ Object
Instance Method Details
#authenticate(unencrypted_token, token_name = :password) ⇒ Object
53 54 55 |
# File 'lib/easy_auth/models/identities/password.rb', line 53 def authenticate(unencrypted_token, token_name = :password) SCrypt::Password.new(send("#{token_name}_digest")) == unencrypted_token && self end |
#generate_reset_token! ⇒ Object
64 65 66 67 68 |
# File 'lib/easy_auth/models/identities/password.rb', line 64 def generate_reset_token! unencrypted_token = _generate_token(:reset_token) update_column(:reset_token_digest, SCrypt::Password.create(unencrypted_token)) unencrypted_token end |
#password=(unencrypted_password) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/easy_auth/models/identities/password.rb', line 57 def password=(unencrypted_password) @password = unencrypted_password unless unencrypted_password.blank? self.password_digest = SCrypt::Password.create(unencrypted_password) end end |