feat(jwtPlugin): correctly check for multiple registration

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Maix0 2025-08-31 16:36:16 +02:00
parent fa3966729f
commit a6ce4630f5

View file

@ -31,7 +31,8 @@ declare module "fastify" {
export const Otp = OTP;
let jwtAdded = false;
export const jwtPlugin = fp<FastifyPluginAsync>(async (fastify, _opts) => {
if (jwtAdded) jwtAdded = true;
if (jwtAdded) return;
jwtAdded = true;
let env = process.env.JWT_SECRET;
if (isNullish(env)) throw "JWT_SECRET is not defined";
if (!fastify.hasDecorator("signJwt")) {