mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
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:
@ -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,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user