diff --git a/src/routes/users.js b/src/routes/users.js index 9e043d5..5cefbb9 100644 --- a/src/routes/users.js +++ b/src/routes/users.js @@ -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); @@ -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 diff --git a/src/utils/user.js b/src/utils/user.js index 2d274d9..2fe4918 100644 --- a/src/utils/user.js +++ b/src/utils/user.js @@ -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};