mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat: add profile_id authentication for business profile update and list (#5673)
This commit is contained in:
@ -3717,6 +3717,7 @@ pub async fn create_business_profile(
|
||||
pub async fn list_business_profile(
|
||||
state: SessionState,
|
||||
merchant_id: id_type::MerchantId,
|
||||
profile_id_list: Option<Vec<id_type::ProfileId>>,
|
||||
) -> RouterResponse<Vec<api_models::admin::BusinessProfileResponse>> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
@ -3732,6 +3733,7 @@ pub async fn list_business_profile(
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?
|
||||
.clone();
|
||||
let profiles = core_utils::filter_objects_based_on_profile_id_list(profile_id_list, profiles);
|
||||
let mut business_profiles = Vec::new();
|
||||
for profile in profiles {
|
||||
let business_profile =
|
||||
|
||||
@ -1334,7 +1334,7 @@ pub fn get_incremental_authorization_allowed_value(
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) trait GetProfileId {
|
||||
pub(crate) trait GetProfileId {
|
||||
fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId>;
|
||||
}
|
||||
|
||||
@ -1381,6 +1381,12 @@ impl<T, F> GetProfileId for (storage::Payouts, T, F) {
|
||||
}
|
||||
}
|
||||
|
||||
impl GetProfileId for domain::BusinessProfile {
|
||||
fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {
|
||||
Some(self.get_id())
|
||||
}
|
||||
}
|
||||
|
||||
/// Filter Objects based on profile ids
|
||||
pub(super) fn filter_objects_based_on_profile_id_list<T: GetProfileId>(
|
||||
profile_id_list_auth_layer: Option<Vec<common_utils::id_type::ProfileId>>,
|
||||
@ -1406,7 +1412,7 @@ pub(super) fn filter_objects_based_on_profile_id_list<T: GetProfileId>(
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn validate_profile_id_from_auth_layer<T: GetProfileId + std::fmt::Debug>(
|
||||
pub(crate) fn validate_profile_id_from_auth_layer<T: GetProfileId + std::fmt::Debug>(
|
||||
profile_id_auth_layer: Option<common_utils::id_type::ProfileId>,
|
||||
object: &T,
|
||||
) -> RouterResult<()> {
|
||||
|
||||
Reference in New Issue
Block a user