From 29cfaccd02b644ec4580db2890b8388b45bd5545 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 9 Nov 2025 18:47:30 +0100 Subject: [PATCH] Fixes --- src/plugins/auth.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/auth.ts b/src/plugins/auth.ts index a62e761..551c3a0 100644 --- a/src/plugins/auth.ts +++ b/src/plugins/auth.ts @@ -1,7 +1,7 @@ import { FastifyInstance } from "fastify"; import fp from "fastify-plugin"; import jwt from "jsonwebtoken"; -import { secrets } from "../utils/secrets.js"; +import { secrets } from "../utils/secrets"; export default fp(async (server: FastifyInstance) => { server.addHook("preHandler", async (req, reply) => { @@ -15,6 +15,16 @@ export default fp(async (server: FastifyInstance) => { const token = headerToken && headerToken.length > 10 ? headerToken : cookieToken || null; + + + /*let token = null + + if(headerToken !== null && headerToken.length > 10){ + token = headerToken + } else if(cookieToken ){ + token = cookieToken + }*/ + if (!token) { return reply.code(401).send({ error: "Authentication required" }); } @@ -27,7 +37,10 @@ export default fp(async (server: FastifyInstance) => { tenant_id: number; }; + console.log("payload", payload); + if (!payload?.user_id || !payload.tenant_id) { + console.log(payload) return reply.code(401).send({ error: "Invalid token" }); }