This commit is contained in:
2026-06-24 14:10:53 +02:00
commit fdb3768d63
122 changed files with 13239 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import { Context } from '@types'
import { MiddlewareFn } from 'type-graphql'
import { User } from '@entities'
export const isAuth: MiddlewareFn<Context> = async ({ context }, next) => {
if (!context.req.session.userId ||
!(await User.findOne({ where: { id: context.req.session.userId } }))
) {
throw new Error('Not authenticated.')
}
await next()
}