Module: Devise::Models::PasswordHashable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/devise/models/password_hashable.rb
Overview
Devise module that transparently re-hashes a user's password to the configured strategy the next time they sign in successfully.
Enable it on a model with:
devise :password_hashable, hashing_strategy: :argon2
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#authenticatable_salt ⇒ String?
The salt used to build the Devise session token.
- #valid_password?(password) ⇒ Boolean
Instance Method Details
#authenticatable_salt ⇒ String?
The salt used to build the Devise session token.
Bcrypt hashes fall through to Devise's own implementation; the other strategies return the salt decoded out of the stored hash.
34 35 36 37 38 39 40 41 |
# File 'lib/devise/models/password_hashable.rb', line 34 def authenticatable_salt # Devise's schema declares encrypted_password as null: false, default: "", # so a user who has never set a password holds "" rather than nil. return if encrypted_password.blank? return super if encrypted_password_strategy == :bcrypt devise_rehash_class(encrypted_password_strategy).split_password_hash(encrypted_password)[:salt] end |
#valid_password?(password) ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/devise/models/password_hashable.rb', line 21 def valid_password?(password) return false unless password_matches?(password) return true if skip_password_migration? migrate_password!(password) end |