refactor(user_roles): Populate role names and entity names in user role APIs (#5861)

This commit is contained in:
Mani Chandra
2024-09-13 18:26:26 +05:30
committed by GitHub
parent 6fc2060620
commit 4d28cf276f
12 changed files with 373 additions and 100 deletions

View File

@ -75,9 +75,14 @@ impl UserFromToken {
}
pub async fn get_role_info_from_db(&self, state: &SessionState) -> UserResult<RoleInfo> {
RoleInfo::from_role_id(state, &self.role_id, &self.merchant_id, &self.org_id)
.await
.change_context(UserErrors::InternalServerError)
RoleInfo::from_role_id_in_merchant_scope(
state,
&self.role_id,
&self.merchant_id,
&self.org_id,
)
.await
.change_context(UserErrors::InternalServerError)
}
}

View File

@ -152,10 +152,11 @@ pub async fn set_role_permissions_in_cache_if_required(
return Ok(());
}
let role_info = roles::RoleInfo::from_role_id(state, role_id, merchant_id, org_id)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Error getting role_info from role_id")?;
let role_info =
roles::RoleInfo::from_role_id_in_merchant_scope(state, role_id, merchant_id, org_id)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Error getting role_info from role_id")?;
authz::set_role_info_in_cache(
state,