feat(jwtPlugin): correctly check for multiple registration
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
fa3966729f
commit
a6ce4630f5
1 changed files with 2 additions and 1 deletions
|
|
@ -31,7 +31,8 @@ declare module "fastify" {
|
||||||
export const Otp = OTP;
|
export const Otp = OTP;
|
||||||
let jwtAdded = false;
|
let jwtAdded = false;
|
||||||
export const jwtPlugin = fp<FastifyPluginAsync>(async (fastify, _opts) => {
|
export const jwtPlugin = fp<FastifyPluginAsync>(async (fastify, _opts) => {
|
||||||
if (jwtAdded) jwtAdded = true;
|
if (jwtAdded) return;
|
||||||
|
jwtAdded = true;
|
||||||
let env = process.env.JWT_SECRET;
|
let env = process.env.JWT_SECRET;
|
||||||
if (isNullish(env)) throw "JWT_SECRET is not defined";
|
if (isNullish(env)) throw "JWT_SECRET is not defined";
|
||||||
if (!fastify.hasDecorator("signJwt")) {
|
if (!fastify.hasDecorator("signJwt")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue