---
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from './isAuth'
|
||||
@@ -0,0 +1,10 @@
|
||||
import { MiddlewareFn } from 'type-graphql'
|
||||
import { Context } from '@/src/types'
|
||||
|
||||
// https://typegraphql.com/docs/middlewares.html
|
||||
export const isAuth: MiddlewareFn<Context> = async ({ context: { req }}, next) => {
|
||||
if (!req.session?.userID) {
|
||||
throw new Error('Unauthenticated!')
|
||||
}
|
||||
return await next()
|
||||
}
|
||||
Reference in New Issue
Block a user