refactor(users): Changes for Home and Signout APIs for TOTP Redis flows (#4851)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Mani Chandra
2024-06-03 19:40:13 +05:30
committed by GitHub
parent 0cbb2928bd
commit d242850b63
3 changed files with 32 additions and 0 deletions

View File

@ -94,6 +94,8 @@ pub async fn get_user_details(
verification_days_left,
role_id: user_from_token.role_id,
org_id: user_from_token.org_id,
is_two_factor_auth_setup: user.get_totp_status() == TotpStatus::Set,
recovery_codes_left: user.get_recovery_codes().map(|codes| codes.len()),
},
))
}
@ -328,6 +330,10 @@ pub async fn signout(
state: SessionState,
user_from_token: auth::UserFromToken,
) -> UserResponse<()> {
tfa_utils::delete_totp_from_redis(&state, &user_from_token.user_id).await?;
tfa_utils::delete_recovery_code_from_redis(&state, &user_from_token.user_id).await?;
tfa_utils::delete_totp_secret_from_redis(&state, &user_from_token.user_id).await?;
auth::blacklist::insert_user_in_blacklist(&state, &user_from_token.user_id).await?;
auth::cookies::remove_cookie_response()
}