From 0d87723438b0cb422a99f85b902c3624867d9201 Mon Sep 17 00:00:00 2001 From: kyrea Date: Thu, 11 Jan 2024 04:47:30 +0530 Subject: [PATCH] fix: destructure 'access-token' in headers --- src/controllers/v3/utils/user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/v3/utils/user.js b/src/controllers/v3/utils/user.js index 5002f38..be8d087 100644 --- a/src/controllers/v3/utils/user.js +++ b/src/controllers/v3/utils/user.js @@ -47,7 +47,7 @@ const userEndpoint = async (req, res, next) => { message: 'Token updated successfully', }); } else if (method === 'GET') { - const { id, email, accessToken } = headers; + const { id, email, 'access-token': access_token } = headers; // Check for required User ID in the headers if (!id) { @@ -66,7 +66,7 @@ const userEndpoint = async (req, res, next) => { email: email, password: crypto.randomBytes(22).toString('base64'), token: generateToken(id, process.env.HMAC_KEY), - access_token: accessToken, + access_token: access_token, // Add other fields in the "newUser" object based on your schema }; @@ -78,7 +78,7 @@ const userEndpoint = async (req, res, next) => { // Update user's token in the database await Users.updateOne( { _id: { $eq: id } }, - { $set: { access_token: accessToken } }, + { $set: { access_token: access_token } }, { upsert: true }, // Create the document if it doesn't exist );