Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
racnan committed Jan 18, 2024
1 parent 2b2a241 commit 5652b9f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/router/src/core/user_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub async fn get_role_from_token(
.attach_printable("Invalid Role Id in JWT")?
.get_permissions()
.iter()
.map(Into::into)
.map(|&per| per.into())
.collect(),
))
}
Expand Down
6 changes: 3 additions & 3 deletions crates/router/src/services/authorization/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ impl PermissionInfo {
pub fn new(permissions: &[Permission]) -> Vec<Self> {
permissions
.iter()
.map(|per| Self {
description: Permission::get_permission_description(per),
enum_name: per.clone(),
.map(|&per| Self {
description: Permission::get_permission_description(&per),
enum_name: per
})
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/services/authorization/permissions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strum::Display;

#[derive(PartialEq, Display, Clone, Debug)]
#[derive(PartialEq, Display, Clone, Debug, Copy)]
pub enum Permission {
PaymentRead,
PaymentWrite,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/types/domain/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ impl From<info::PermissionModule> for user_role_api::PermissionModule {
impl From<info::PermissionInfo> for user_role_api::PermissionInfo {
fn from(value: info::PermissionInfo) -> Self {
Self {
enum_name: (&value.enum_name).into(),
enum_name: value.enum_name.into(),
description: value.description,
}
}
Expand Down
21 changes: 12 additions & 9 deletions crates/router/src/utils/user_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ pub fn validate_role_id(role_id: &str) -> UserResult<()> {
pub fn get_role_name_and_permission_response(
role_info: &RoleInfo,
) -> Option<(Vec<user_role_api::Permission>, &'static str)> {
role_info
.get_permissions()
.iter()
.map(TryInto::try_into)
.collect::<Result<Vec<user_role_api::Permission>, _>>()
.ok()
.zip(role_info.get_name())
role_info.get_name().map(|name| {
(
role_info
.get_permissions()
.iter()
.map(|&per| per.into())
.collect::<Vec<user_role_api::Permission>>(),
name,
)
})
}

impl From<&Permission> for user_role_api::Permission {
fn from(value: &Permission) -> Self {
impl From<Permission> for user_role_api::Permission {
fn from(value: Permission) -> Self {
match value {
Permission::PaymentRead => Self::PaymentRead,
Permission::PaymentWrite => Self::PaymentWrite,
Expand Down

0 comments on commit 5652b9f

Please sign in to comment.