auth required works

This commit is contained in:
2026-01-15 23:15:33 +00:00
parent 157e5180b8
commit 8a3dad4a5f

View File

@@ -2,8 +2,14 @@
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
// this one requires auth // this one requires auth
//const login = fetch("http://127.0.0.1:81/login"); //const login = fetch("http://127.0.0.1:81/login");
console.log(await readBody(event))
const session = await getUserSession(event) const session = await getUserSession(event)
if (session.secure!.user_id == undefined) console.log(session)
throw createError({ statusCode: 401 }); try {
const userId = session.secure!.user_id;
}
catch {
throw createError({ status: 401 })
}
}) })