Skip to content

Commit

Permalink
fix: destructure 'access-token' in headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrea committed Jan 10, 2024
1 parent 57f5eac commit 0d87723
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/controllers/v3/utils/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
};

Expand All @@ -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
);

Expand Down

0 comments on commit 0d87723

Please sign in to comment.