From b2070656ccf152b4e198837564179c6fbbee1628 Mon Sep 17 00:00:00 2001 From: Luxshan2000 Date: Wed, 1 Nov 2023 12:56:10 +0530 Subject: [PATCH] debugging --- backend/package-lock.json | 50 +++++++++++++++++++++++ backend/src/controllers/authController.js | 18 ++++---- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/backend/package-lock.json b/backend/package-lock.json index 8f88111..2a0e6f2 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -5676,6 +5676,19 @@ "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "peer": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -6524,6 +6537,33 @@ "node": ">= 0.8" } }, + "node_modules/react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "dev": true, + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", + "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "dev": true, + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -6685,6 +6725,16 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/scheduler": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", + "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "dev": true, + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", diff --git a/backend/src/controllers/authController.js b/backend/src/controllers/authController.js index f7ec99a..8c563c2 100644 --- a/backend/src/controllers/authController.js +++ b/backend/src/controllers/authController.js @@ -86,16 +86,20 @@ const login = async (req, res, isWeb) => { .json({ error: "Incorrect password", success: false }); } else { // If the username and password are correct, generate a JWT token - const token = jwt.sign( - { name: user.name, isVerified: user.isVerified, email: user.email }, - process.env.SECURITY_KEY, - { expiresIn: "5hour" } - ); + // const token = jwt.sign( + // { name: user.name, isVerified: user.isVerified, email: user.email }, + // process.env.SECURITY_KEY, + // { expiresIn: "5hour" } + // ); if (isWeb) { const oneWeekInSeconds = 7 * 24 * 60 * 60; // 7 days * 24 hours * 60 minutes * 60 seconds const expirationDate = new Date(Date.now() + oneWeekInSeconds * 1000); // Convert seconds to milliseconds - res.cookie("token", token, { - expires: expirationDate, + // res.cookie("token", token, { + // expires: expirationDate, + // }); + + res.cookie("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiRHJpdmVTbWFydCIsImlzVmVyaWZpZWQiOnRydWUsImVtYWlsIjoic2xkcml2ZXNtYXJ0QGdtYWlsLmNvbSIsImlhdCI6MTY5ODc3NjI2MSwiZXhwIjoxNjk5MzgxMDYxfQ.2EAPdS7NbDyoB4jnB4bfZwQGryVsU48ueisu-Jipu9o",{ + expires: expirationDate }); // Send the token in the response res.json({ message: "Login successful" });