fix(api): preHandler return type for requireAuth; clean oauth.ts
This commit is contained in:
parent
648427000d
commit
ea1ec1e801
@ -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 session = await getSession(token);
|
||||
if (!session) {
|
||||
reply.code(401).send({ error: 'unauthorized' });
|
||||
return reply;
|
||||
return reply.code(401).send({ error: 'unauthorized' });
|
||||
}
|
||||
req.user = session;
|
||||
}
|
||||
|
||||
@ -257,8 +257,6 @@ export async function oauthRoutes(app: FastifyInstance): Promise<void> {
|
||||
scopes_supported: ['mcp:read', 'mcp:write'],
|
||||
});
|
||||
});
|
||||
|
||||
void config;
|
||||
}
|
||||
|
||||
function reqBase(req: { protocol?: string; headers: Record<string, string | string[] | undefined> }): string {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user