Skip to content

Commit

Permalink
fix(users.js): update bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
supersonictw committed Oct 14, 2024
1 parent ee383e7 commit 5c9b75f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ router.put("/me",
}

// Handle updates
user.nickname =
req?.body?.nickname ||
user.nickname = req?.body?.nickname ||
req.auth.metadata.profile.nickname;

// Update values
const userData = await utilUser.saveData(user);

// Generate token
const token = utilXaraToken.
update(req.auth.secret, userData);

Expand Down Expand Up @@ -267,8 +268,10 @@ router.patch("/me/email",
return;
}

// Update values
// Handle updates
user.email = metadata.data.email;

// Update values
const userData = utilUser.saveData(user);

// Generate token
Expand Down
3 changes: 2 additions & 1 deletion src/utils/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const {getPosixTimestamp} = require("../utils/native");
*/
async function saveData(user) {
user.updated_at = getPosixTimestamp();
return await user.save();
const newUser = await user.save();
return newUser.toObject();
}

module.exports = {saveData};

0 comments on commit 5c9b75f

Please sign in to comment.