pub trait SecurePassword {
Show 13 methods
// Required methods
fn password_digest(&self) -> Option<&str>;
fn set_password_digest(&mut self, digest: String);
// Provided methods
fn set_password(
&mut self,
password: &str,
) -> Result<(), SecurePasswordError> { ... }
fn set_password_confirmed(
&mut self,
password: &str,
confirmation: Option<&str>,
) -> Result<(), SecurePasswordError> { ... }
fn update_password(
&mut self,
password: &str,
) -> Result<bool, SecurePasswordError> { ... }
fn update_password_confirmed(
&mut self,
password: &str,
confirmation: Option<&str>,
) -> Result<bool, SecurePasswordError> { ... }
fn set_password_with_algorithm(
&mut self,
password: &str,
algorithm: &str,
) -> Result<(), SecurePasswordError> { ... }
fn authenticate(&self, password: &str) -> Result<bool, SecurePasswordError> { ... }
fn authenticate_password(&self, challenge: Option<&str>) -> bool { ... }
fn generate_recovery_token(&self) -> Result<String, SecurePasswordError> { ... }
fn verify_recovery_token(&self, token: &str) -> bool { ... }
fn has_password(&self) -> bool { ... }
fn password_salt(&self) -> Option<String> { ... }
}Expand description
Trait for models that store a password digest.
Required Methods§
Sourcefn password_digest(&self) -> Option<&str>
fn password_digest(&self) -> Option<&str>
Returns the stored password digest, if one exists.
Sourcefn set_password_digest(&mut self, digest: String)
fn set_password_digest(&mut self, digest: String)
Replaces the stored password digest.
Provided Methods§
Sourcefn set_password(&mut self, password: &str) -> Result<(), SecurePasswordError>
fn set_password(&mut self, password: &str) -> Result<(), SecurePasswordError>
Hashes and stores a password using the default algorithm registry entry.
Sourcefn set_password_confirmed(
&mut self,
password: &str,
confirmation: Option<&str>,
) -> Result<(), SecurePasswordError>
fn set_password_confirmed( &mut self, password: &str, confirmation: Option<&str>, ) -> Result<(), SecurePasswordError>
Hashes and stores a password when the optional confirmation matches.
Sourcefn update_password(
&mut self,
password: &str,
) -> Result<bool, SecurePasswordError>
fn update_password( &mut self, password: &str, ) -> Result<bool, SecurePasswordError>
Updates an existing digest, treating a blank password as “no change”.
Sourcefn update_password_confirmed(
&mut self,
password: &str,
confirmation: Option<&str>,
) -> Result<bool, SecurePasswordError>
fn update_password_confirmed( &mut self, password: &str, confirmation: Option<&str>, ) -> Result<bool, SecurePasswordError>
Updates an existing digest with optional confirmation, treating a blank password as “no change”.
Sourcefn set_password_with_algorithm(
&mut self,
password: &str,
algorithm: &str,
) -> Result<(), SecurePasswordError>
fn set_password_with_algorithm( &mut self, password: &str, algorithm: &str, ) -> Result<(), SecurePasswordError>
Hashes and stores a password using a registered algorithm.
Sourcefn authenticate(&self, password: &str) -> Result<bool, SecurePasswordError>
fn authenticate(&self, password: &str) -> Result<bool, SecurePasswordError>
Verifies a password against the stored digest.
Sourcefn authenticate_password(&self, challenge: Option<&str>) -> bool
fn authenticate_password(&self, challenge: Option<&str>) -> bool
Verifies an optional challenge and returns false for missing, blank, or malformed inputs.
Sourcefn generate_recovery_token(&self) -> Result<String, SecurePasswordError>
fn generate_recovery_token(&self) -> Result<String, SecurePasswordError>
Generates a self-contained recovery token bound to the current password digest.
Sourcefn verify_recovery_token(&self, token: &str) -> bool
fn verify_recovery_token(&self, token: &str) -> bool
Verifies a recovery token against the current password digest.
Sourcefn has_password(&self) -> bool
fn has_password(&self) -> bool
Returns true when a password digest is present.
Sourcefn password_salt(&self) -> Option<String>
fn password_salt(&self) -> Option<String>
Extracts the salt encoded in the current password digest.