refactor: session handling (#2398)

* refactor session handling

* simplify
This commit is contained in:
Bernd Storath
2026-01-13 10:11:13 +01:00
committed by GitHub
parent b85286f0ab
commit 51558c7027
11 changed files with 38 additions and 31 deletions
+7 -2
View File
@@ -1,9 +1,14 @@
import type { SharedPublicUser } from '~~/shared/utils/permissions';
export default defineEventHandler(async (event) => {
const session = await useWGSession(event);
if (!session.data.userId) {
// not logged in
return null;
throw createError({
statusCode: 401,
statusMessage: 'Not authenticated',
});
}
const user = await Database.users.get(session.data.userId);
@@ -21,5 +26,5 @@ export default defineEventHandler(async (event) => {
name: user.name,
email: user.email,
totpVerified: user.totpVerified,
};
} satisfies SharedPublicUser;
});