Fix errors (#7134)
parent
f77e7476d2
commit
ce01537fe6
|
@ -91,6 +91,7 @@ const ImpersonationProvider = CredentialsProvider({
|
|||
select: {
|
||||
teamId: true,
|
||||
disableImpersonation: true,
|
||||
role: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -135,6 +136,9 @@ const ImpersonationProvider = CredentialsProvider({
|
|||
},
|
||||
],
|
||||
},
|
||||
select: {
|
||||
role: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -143,6 +147,11 @@ const ImpersonationProvider = CredentialsProvider({
|
|||
throw new Error("You do not have permission to do this.");
|
||||
}
|
||||
|
||||
// We find team by ID so we know there is only one team in the array
|
||||
if (sessionUserFromDb?.teams[0].role === "ADMIN" && impersonatedUser.teams[0].role === "OWNER") {
|
||||
throw new Error("You do not have permission to do this.");
|
||||
}
|
||||
|
||||
return auditAndReturnNextUser(
|
||||
impersonatedUser,
|
||||
session?.user.id as number,
|
||||
|
|
Loading…
Reference in New Issue