feat(user_roles): support switch for new hierarchy (#5692)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Apoorv Dixit
2024-08-28 13:30:07 +05:30
committed by GitHub
parent 771f48cfe0
commit 53b3163881
11 changed files with 559 additions and 27 deletions

View File

@ -108,16 +108,16 @@ pub async fn generate_jwt_auth_token_without_profile(
Ok(Secret::new(token))
}
pub async fn generate_jwt_auth_token_with_custom_role_attributes(
pub async fn generate_jwt_auth_token_with_attributes(
state: &SessionState,
user: &UserFromStorage,
user_id: String,
merchant_id: id_type::MerchantId,
org_id: id_type::OrganizationId,
role_id: String,
profile_id: Option<id_type::ProfileId>,
) -> UserResult<Secret<String>> {
let token = AuthToken::new_token(
user.get_user_id().to_string(),
user_id,
merchant_id,
role_id,
&state.conf,

View File

@ -128,6 +128,18 @@ pub async fn set_role_permissions_in_cache_by_user_role(
.is_ok()
}
pub async fn set_role_permissions_in_cache_by_role_id_merchant_id_org_id(
state: &SessionState,
role_id: &str,
merchant_id: &id_type::MerchantId,
org_id: &id_type::OrganizationId,
) -> bool {
set_role_permissions_in_cache_if_required(state, role_id, merchant_id, org_id)
.await
.map_err(|e| logger::error!("Error setting permissions in cache {:?}", e))
.is_ok()
}
pub async fn set_role_permissions_in_cache_if_required(
state: &SessionState,
role_id: &str,