feat(recon): add merchant and profile IDs in auth tokens (#5643)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Kashif
2024-09-06 19:55:40 +05:30
committed by GitHub
parent 36cd5c1c41
commit d9485a5f36
30 changed files with 339 additions and 339 deletions

View File

@ -1821,30 +1821,23 @@ pub async fn send_verification_mail(
#[cfg(feature = "recon")]
pub async fn verify_token(
state: SessionState,
req: auth::ReconUser,
user: auth::UserFromToken,
) -> UserResponse<user_api::VerifyTokenResponse> {
let user = state
let user_in_db = state
.global_store
.find_user_by_id(&req.user_id)
.find_user_by_id(&user.user_id)
.await
.map_err(|e| {
if e.current_context().is_db_not_found() {
e.change_context(UserErrors::UserNotFound)
} else {
e.change_context(UserErrors::InternalServerError)
}
.change_context(UserErrors::InternalServerError)
.attach_printable_lazy(|| {
format!(
"Failed to fetch the user from DB for user_id - {}",
user.user_id
)
})?;
let merchant_id = state
.store
.find_user_role_by_user_id(&req.user_id, UserRoleVersion::V1)
.await
.change_context(UserErrors::InternalServerError)?
.merchant_id
.ok_or(UserErrors::InternalServerError)?;
Ok(ApplicationResponse::Json(user_api::VerifyTokenResponse {
merchant_id: merchant_id.to_owned(),
user_email: user.email,
merchant_id: user.merchant_id.to_owned(),
user_email: user_in_db.email,
}))
}