Added JWT to registration and login
This commit is contained in:
1 parent
35cc81b3c5
commit
b1afdaa776
5 files changed
+130
-35
No files matched your search
+3
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user