Files
libnovel/ui/src/routes/api/auth/me/+server.ts
Admin 5a7d7ce3b9
Some checks failed
Deploy / Deploy Production (push) Has been skipped
Deploy / Cleanup Preview (push) Has been skipped
Deploy / Deploy Preview (push) Failing after 1s
CI / Scraper / Lint (pull_request) Failing after 17s
CI / UI / Build (pull_request) Successful in 25s
CI / Scraper / Test (pull_request) Successful in 27s
CI / Scraper / Build (pull_request) Has been skipped
iOS CI / Build (pull_request) Failing after 1s
iOS CI / Test (pull_request) Has been skipped
fix: remove non-existent created field from auth/me and fix html declaration order in chapter page
2026-03-08 22:28:08 +05:00

19 lines
457 B
TypeScript

import { json, error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
/**
* GET /api/auth/me
* Returns the currently authenticated user from the request's auth cookie.
* Returns 401 if not authenticated.
*/
export const GET: RequestHandler = async ({ locals }) => {
if (!locals.user) {
error(401, 'Not authenticated');
}
return json({
id: locals.user.id,
username: locals.user.username,
role: locals.user.role
});
};