d5939db
//! Method-style wrappers around [`crate::features::password_hash::usecase`].
//!
//! Most of the heavy lifting is exposed as free functions; the impl block here
//! is for ergonomic call sites that hold an [`AuthService`].
use super::{PasswordHashString, PasswordInput, ValidatePasswordRequest};
use super::usecase::{hash_password, validate_password, verify_password};
use crate::error::AuthError;
use crate::features::AuthService;
impl AuthService {
pub fn hash_password(&self, password: &str) -> Result<PasswordHashString, AuthError> {
hash_password(PasswordInput { password })
}
pub fn verify_password(
&self,
password: &str,
hash: &PasswordHashString,
) -> Result<bool, AuthError> {
verify_password(PasswordInput { password }, hash)
}
pub fn validate_password(&self, password: &str) -> Result<(), AuthError> {
validate_password(
ValidatePasswordRequest { password },
&self.config.password_policy,
)
}
}