Added JWT to registration and login

This commit is contained in:
Alex Holliday committed 2024-05-22 10:48:58 -07:00
1 parent 35cc81b3c5
commit b1afdaa776
5 files changed
+130 -35

No files matched your search

+3 -1
View File
@@ -41,7 +41,9 @@ const insertUser = async (req, res) => {
const salt = await bcrypt.genSalt(10); //genSalt is asynchronous, need to wait
newUser.password = await bcrypt.hash(newUser.password, salt); // hash is also async, need to eitehr await or use hashSync
USERS.push(newUser);
return newUser;
const userToReturn = { ...newUser._doc };
delete userToReturn.password;
return userToReturn;
} catch (error) {
throw error;
}