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 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user