Add permission checks.

This commit is contained in:
Brian Cao 2022-11-20 00:48:13 -08:00
parent 51e2331315
commit 78225691df
20 changed files with 225 additions and 333 deletions

View file

@ -19,6 +19,27 @@ export async function getPermissions(where: Prisma.PermissionWhereInput): Promis
});
}
export async function getPermissionsByUserId(userId, name?: string): Promise<Permission[]> {
return prisma.client.permission.findMany({
where: {
...(name ? { name } : {}),
RolePermission: {
every: {
role: {
is: {
userRoles: {
every: {
userId,
},
},
},
},
},
},
},
});
}
export async function updatePermission(
data: Prisma.PermissionUpdateInput,
where: Prisma.PermissionWhereUniqueInput,