Class: Devise::Hashable::Strategy::Base Abstract
- Inherits:
-
Object
- Object
- Devise::Hashable::Strategy::Base
- Defined in:
- lib/devise/hashable/strategy/base.rb
Overview
Subclass and override Base.compare, Base.digest, Base.password_configurations_match? and Base.split_password_hash.
The base class for each hashing strategy.
Subclasses implement the four class methods below. Every strategy is stateless: the Devise model class is passed in so the strategy can read the configuration (stretches, iterations, profile) it needs.
Class Method Summary collapse
-
.compare(_klass, _encrypted_password, _password) ⇒ Boolean
Verifies a plain-text password against an existing hash.
-
.digest(_klass, _password) ⇒ String
Hashes a plain-text password using the strategy's configuration.
-
.password_configurations_match?(_klass, _encrypted_password) ⇒ Boolean
Whether an existing hash was produced with the currently configured parameters.
-
.split_password_hash(_encrypted_password) ⇒ Hash
Splits an encoded password hash into its component parts.
Class Method Details
.compare(_klass, _encrypted_password, _password) ⇒ Boolean
Verifies a plain-text password against an existing hash.
23 24 25 |
# File 'lib/devise/hashable/strategy/base.rb', line 23 def compare(_klass, _encrypted_password, _password) raise NotImplementedError, "You need to implement the 'compare' method in your custom hashing strategy" end |
.digest(_klass, _password) ⇒ String
Hashes a plain-text password using the strategy's configuration.
33 34 35 |
# File 'lib/devise/hashable/strategy/base.rb', line 33 def digest(_klass, _password) raise NotImplementedError, "You need to implement the 'digest' method in your custom hashing strategy" end |
.password_configurations_match?(_klass, _encrypted_password) ⇒ Boolean
Whether an existing hash was produced with the currently configured parameters. A false result means the password needs re-hashing.
44 45 46 |
# File 'lib/devise/hashable/strategy/base.rb', line 44 def password_configurations_match?(_klass, _encrypted_password) raise NotImplementedError, "You need to implement the 'password_configurations_match?' method in your custom hashing strategy" end |
.split_password_hash(_encrypted_password) ⇒ Hash
Splits an encoded password hash into its component parts.
53 54 55 |
# File 'lib/devise/hashable/strategy/base.rb', line 53 def split_password_hash(_encrypted_password) raise NotImplementedError, "You need to implement the 'split_password_hash' method in your custom hashing strategy" end |