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