Skip to content

Commit 39ce3bd

Browse files
committed
Update validation when removing a user that does not have the specified role
1 parent d8b9d5a commit 39ce3bd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pallets/proxy/src/functions.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,8 @@ impl<T: Config> Pallet<T> {
375375
ensure!(<UsersByProject<T>>::get(project_id).contains(&user.clone()), Error::<T>::UserNotAssignedToProject);
376376
ensure!(<ProjectsByUser<T>>::get(user.clone()).contains(&project_id), Error::<T>::UserNotAssignedToProject);
377377

378-
// Ensure user has roles assigned to the project
379-
// TODO: catch error and return custom error
380-
//ensure!(T::Rbac::has_role(user.clone(), Self::pallet_id(), &project_id, [role.id()].to_vec()).is_ok(), Error::<T>::UserDoesNotHaveRole);
381-
T::Rbac::has_role(user.clone(), Self::pallet_id(), &project_id, [role.id()].to_vec())?;
378+
// Ensure user has the specified role assigned in the selected project
379+
ensure!(T::Rbac::has_role(user.clone(), Self::pallet_id(), &project_id, [role.id()].to_vec()).is_ok(), Error::<T>::UserDoesNotHaveRole);
382380

383381
// Update project data depending on the role unassigned
384382
Self::remove_project_role(project_id, user.clone(), role)?;

pallets/proxy/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ pub mod pallet {
431431
TransactionIsAlreadyCompleted,
432432
/// Expenditure type does not match project type
433433
InvalidExpenditureType,
434+
/// User does not have the specified role
435+
UserDoesNotHaveRole,
434436

435437
}
436438

0 commit comments

Comments
 (0)