diff --git a/server/middleware/auth-middleware.ts b/server/middleware/auth-middleware.ts index 63a7aa6..db5b289 100644 --- a/server/middleware/auth-middleware.ts +++ b/server/middleware/auth-middleware.ts @@ -13,16 +13,17 @@ declare module 'h3' { export default defineEventHandler((event) => { - // const appAuth = getCookie(event, 'app-auth') - // if (appAuth) { - // const verifiedData = jsonwebtoken.verify(appAuth, JWT_KEY) - // // if (!verifiedData) { - // // deleteCookie(event, 'app-auth') - // // } - // // @ts-ignore - // const userId = verifiedData.userId - // event.context.auth = { userId: userId } - // } else { - // } - event.context.auth = { userId: 1 } + const appAuth = getCookie(event, 'app-auth') + if (appAuth) { + const verifiedData = jsonwebtoken.verify(appAuth, JWT_KEY) + // if (!verifiedData) { + // deleteCookie(event, 'app-auth') + // } + // @ts-ignore + const userId = verifiedData.userId + event.context.auth = { userId: userId } + } else { + console.log('user not logged in') + event.context.auth = { userId: 1 } + } })