mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Cleanup relation schema
This commit is contained in:
parent
781a9ae216
commit
a8d253fa2e
10 changed files with 404 additions and 291 deletions
|
|
@ -14,10 +14,10 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
|||
context.locals.session = isAuthed.session
|
||||
|
||||
const user = await prismaClient.users.findUnique({
|
||||
select: { roleList: { select: { roles: { select: { permissions: true } } } } },
|
||||
select: { roles: { select: { roles: { select: { permissions: true } } } } },
|
||||
where: { id: isAuthed.user.id }
|
||||
})
|
||||
const permissions = (user?.roleList.map((r) => r.roles.permissions).flat() as string[]) ?? []
|
||||
const permissions = (user?.roles.map((r) => r.roles.permissions).flat() as string[]) ?? []
|
||||
const pages = PAGES.filter((p) => p.perms.some((r) => permissions.includes(r))).map((p) => p.url)
|
||||
|
||||
context.locals.permissions = permissions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue