From cf69255acdfd70a05459cf6e9c8b0ca6404dbe26 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Tue, 7 Feb 2023 11:30:32 -0500 Subject: [PATCH] fix totp authentication --- trifid-api/src/tokens.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trifid-api/src/tokens.rs b/trifid-api/src/tokens.rs index 6021278..58da308 100644 --- a/trifid-api/src/tokens.rs +++ b/trifid-api/src/tokens.rs @@ -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> { - 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) } \ No newline at end of file