diff options
feat: oidc attempt 82845345
Diffstat (limited to 'src/routes/api/v1/whoami/+server.ts')
| -rw-r--r-- | src/routes/api/v1/whoami/+server.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/routes/api/v1/whoami/+server.ts b/src/routes/api/v1/whoami/+server.ts new file mode 100644 index 0000000..98809a4 --- /dev/null +++ b/src/routes/api/v1/whoami/+server.ts @@ -0,0 +1,9 @@ +import { error, json } from '@sveltejs/kit'; +import { filterSession, type Session } from '../../../../hooks.server.js'; + +export const GET = async ({ locals }) => { + const data = (await locals.auth()) as Session; + if (data === undefined) throw error(403, 'Unauthorized'); + if (data === null) throw error(401, 'Session Expired'); + return json(filterSession(data)); +}; |