Fix errors (#7134)

pull/7181/head
sean-brydon 2023-02-17 11:15:42 +00:00 committed by GitHub
parent f77e7476d2
commit ce01537fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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,