MCPcopy
hub / github.com/Peppermint-Lab/peppermint / authenticateUser

Function authenticateUser

apps/api/src/lib/checks.ts:5–19  ·  view source on GitHub ↗
(
  request: FastifyRequest,
  reply: FastifyReply,
  done: any
)

Source from the content-addressed store, hash-verified

3
4// Check valid token
5export const authenticateUser = (
6 request: FastifyRequest,
7 reply: FastifyReply,
8 done: any
9) => {
10 const bearer = request.headers.authorization!.split(" ")[1];
11 const token = checkToken(bearer);
12
13 if (!token) {
14 return reply.code(401).send({ error: "Unauthorized" });
15 }
16
17 // User is authenticated, continue to the route handler
18 done();
19};

Callers

nothing calls this directly

Calls 1

checkTokenFunction · 0.90

Tested by

no test coverage detected