pub async fn reset_password(pool: &DBPool, password_reset_id: String, new_password: String) -> Result<()> {
        prune_password_resets(pool).await?;

        let valid = password_reset_exists(pool, password_reset_id.clone()).await?;

        if valid {
            let user = get_user_by_password_reset(pool, password_reset_id.clone()).await?;
            delete_password_reset(pool, password_reset_id.clone()).await?;
            services::user_service::set_password(pool, user.id, new_password).await?;

            Ok(())
        } else {
            Err(Error::new(ErrorKind::Other, "Invalid password reset ID"))
        }
    }
/// Resets a user's password and deletes the password reset record
/// 
/// # Arguments
/// 
/// * `pool` - The database pool
/// * `password_reset_id` - The ID of the password reset record
/// * `new_password` - The user's new password
Resets a user's password and deletes the password reset record
Resets a user ' s password and deletes the password reset record
pub async fn reset_password(pool: &DBPool, password_reset_id: String, new_password: String) -> Result<()> {
        prune_password_resets(pool).await?;
        let valid = password_reset_exists(pool, password_reset_id.clone()).await?;
        if valid {
            let user = get_user_by_password_reset(pool, password_reset_id.clone()).await?;
            delete_password_reset(pool, password_reset_id.clone()).await?;
            services::user_service::set_password(pool, user.id, new_password).await?;
            Ok(())
        } else {
            Err(Error::new(ErrorKind::Other, "Invalid password reset ID"))
        }
    }
pub async fn reset_password ( pool : & DBPool , password_reset_id : String , new_password : String ) -> Result < ( ) > { prune_password_resets ( pool ) . await ? ; let valid = password_reset_exists ( pool , password_reset_id . clone ( ) ) . await ? ; if valid { let user = get_user_by_password_reset ( pool , password_reset_id . clone ( ) ) . await ? ; delete_password_reset ( pool , password_reset_id . clone ( ) ) . await ? ; services :: user_service :: set_password ( pool , user . id , new_password ) . await ? ; Ok ( ( ) ) } else { Err ( Error :: new ( ErrorKind :: Other , " " ) ) } }
Resets a user's password and deletes the password reset record
Resets a user ' s password and deletes the password reset record
pool
&DBPool
password_reset_id
String
new_password
String
pool
&DBPool
password_reset_id
String
new_password
String