Fix admin being able to update owner details (#13534)
This commit is contained in:
1 parent
f09153b3bb
commit
bab182960f
1 file changed
+9
-1
@@ -37,8 +37,16 @@ export const updateUserHandler = async ({ ctx, input }: UpdateUserOptions) => {
|
||||
|
||||
if (!(await isOrganisationAdmin(userId, organizationId))) throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
|
||||
const isUpdaterAnOwner = await isOrganisationOwner(userId, organizationId);
|
||||
// only OWNER can update the role to OWNER
|
||||
if (input.role === MembershipRole.OWNER && !(await isOrganisationOwner(userId, organizationId))) {
|
||||
if (input.role === MembershipRole.OWNER && !isUpdaterAnOwner) {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
|
||||
const isUserBeingUpdatedOwner = await isOrganisationOwner(input.userId, organizationId);
|
||||
|
||||
// only owner can update the role of another owner
|
||||
if (isUserBeingUpdatedOwner && !isUpdaterAnOwner) {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user