fix totp authentication

This commit is contained in:
c0repwn3r 2023-02-07 11:30:32 -05:00
parent fffcf5ee8f
commit cf69255acd
Signed by: core
GPG Key ID: FDBF740DADDCEECF
1 changed files with 2 additions and 1 deletions

View File

@ -76,7 +76,8 @@ pub async fn verify_totp_token(otpid: String, email: String, db: &PgPool) -> Res
}
pub async fn use_totp_token(otpid: String, email: String, db: &PgPool) -> Result<TOTP, Box<dyn Error>> {
let totpmachine = verify_totp_token(otpid.clone(), email, db).await?;
let totpmachine = verify_totp_token(otpid.clone(), email.clone(), db).await?;
sqlx::query!("DELETE FROM totp_create_tokens WHERE id = $1", otpid).execute(db).await?;
sqlx::query!("UPDATE users SET totp_otpurl = $1, totp_secret = $2, totp_verified = 1 WHERE email = $3", totpmachine.get_url(), totpmachine.get_secret_base32(), email).execute(db).await?;
Ok(totpmachine)
}