Skip to content

Commit

Permalink
fix admin (not super) not being authorized to update users
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Jul 22, 2024
1 parent e492d17 commit 2c133cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/src/services/UserServices/UpdateUserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ const UpdateUserService = async ({

const requestUser = await User.findByPk(requestUserId);

if (
(requestUser.super === false && userData.companyId !== requestUser.companyId) ||
(requestUser.profile !== "admin" && +userId !== requestUser.id )
if (
!requestUser.super &&
+userId !== requestUser.id &&
(user.companyId !== requestUser.companyId ||
requestUser.profile !== "admin")
) {
throw new AppError("ERR_FORBIDDEN", 403);
}
Expand Down

0 comments on commit 2c133cf

Please sign in to comment.