feat(recon): add recon APIs (#3345)

Co-authored-by: Kashif <mohammed.kashif@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Kashif
2024-01-16 16:37:44 +05:30
committed by GitHub
parent 5ad3f8939a
commit 8678f8d144
22 changed files with 639 additions and 7 deletions

View File

@ -757,3 +757,32 @@ pub async fn send_verification_mail(
Ok(ApplicationResponse::StatusOk)
}
#[cfg(feature = "recon")]
pub async fn verify_token(
state: AppState,
req: auth::ReconUser,
) -> UserResponse<user_api::VerifyTokenResponse> {
let user = state
.store
.find_user_by_id(&req.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)
}
})?;
let merchant_id = state
.store
.find_user_role_by_user_id(&req.user_id)
.await
.change_context(UserErrors::InternalServerError)?
.merchant_id;
Ok(ApplicationResponse::Json(user_api::VerifyTokenResponse {
merchant_id: merchant_id.to_string(),
user_email: user.email,
}))
}