fix(api): preHandler return type for requireAuth; clean oauth.ts

This commit is contained in:
Marco Sadjadi 2026-05-19 00:36:42 +02:00
parent 648427000d
commit ea1ec1e801
2 changed files with 5 additions and 5 deletions

View File

@ -9,12 +9,14 @@ declare module 'fastify' {
} }
} }
export async function requireAuth(req: FastifyRequest, reply: FastifyReply): Promise<void> { export async function requireAuth(
req: FastifyRequest,
reply: FastifyReply,
): Promise<FastifyReply | void> {
const token = req.cookies[SESSION_COOKIE]; const token = req.cookies[SESSION_COOKIE];
const session = await getSession(token); const session = await getSession(token);
if (!session) { if (!session) {
reply.code(401).send({ error: 'unauthorized' }); return reply.code(401).send({ error: 'unauthorized' });
return reply;
} }
req.user = session; req.user = session;
} }

View File

@ -257,8 +257,6 @@ export async function oauthRoutes(app: FastifyInstance): Promise<void> {
scopes_supported: ['mcp:read', 'mcp:write'], scopes_supported: ['mcp:read', 'mcp:write'],
}); });
}); });
void config;
} }
function reqBase(req: { protocol?: string; headers: Record<string, string | string[] | undefined> }): string { function reqBase(req: { protocol?: string; headers: Record<string, string | string[] | undefined> }): string {