fix(routing): handle validation for profile_id (#9809)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Ankit Kumar Gupta
2025-10-17 19:25:20 +05:30
committed by GitHub
parent b42fbdb50f
commit bfa06b2108

View File

@ -1871,9 +1871,10 @@ pub async fn validate_and_get_business_profile(
) -> RouterResult<Option<domain::Profile>> {
profile_id
.async_map(|profile_id| async {
db.find_business_profile_by_profile_id(
db.find_business_profile_by_merchant_id_profile_id(
key_manager_state,
merchant_key_store,
merchant_id,
profile_id,
)
.await
@ -1882,18 +1883,6 @@ pub async fn validate_and_get_business_profile(
})
})
.await
.transpose()?
.map(|business_profile| {
// Check if the merchant_id of business profile is same as the current merchant_id
if business_profile.merchant_id.ne(merchant_id) {
Err(errors::ApiErrorResponse::AccessForbidden {
resource: business_profile.get_id().get_string_repr().to_owned(),
}
.into())
} else {
Ok(business_profile)
}
})
.transpose()
}