From 3cc66f4e9707eeceaf1a165ee54eb623d19d35bf Mon Sep 17 00:00:00 2001 From: Anika Raemer Date: Wed, 24 Sep 2025 20:39:33 +0200 Subject: [PATCH] Fix token --- .env | 1 + src/utils/encryptionUtils.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 0ba7bcc..367fdf5 100644 --- a/.env +++ b/.env @@ -6,3 +6,4 @@ DB_USERNAME=recipe-backend DB_PASSWORD=yeshu0bue5aigaphie0eemoFey3farei DB_DATABASE=recipe-backend-dev NODE_ENV=dev +JWT_SECRET=m+rQLREpPDTjaiD2nh4IIeu/y9Y5rWB8pyiOTBIgUtRiPpxp4dFeJ9iV1KL7Mfa+ZczvJnZanoXVLWS80lq0wg== diff --git a/src/utils/encryptionUtils.ts b/src/utils/encryptionUtils.ts index 740c2dc..bc833f2 100644 --- a/src/utils/encryptionUtils.ts +++ b/src/utils/encryptionUtils.ts @@ -1,6 +1,6 @@ -import * as jwt from "jsonwebtoken"; -import * as bcrypt from "bcrypt"; -import * as dotenv from "dotenv"; +import jwt from "jsonwebtoken"; +import bcrypt from "bcrypt"; +import dotenv from "dotenv"; dotenv.config(); const { JWT_SECRET = "" } = process.env; @@ -16,4 +16,8 @@ export class encrypt { // @todo currently, we have an error here! return jwt.sign(payload, JWT_SECRET, { expiresIn: "1d" }); } -} \ No newline at end of file + + static verifyToken(token: string) { + return jwt.verify(token, JWT_SECRET); + } +}