return error when register user with used email:

This commit is contained in:
Adolfo Reyna
2021-09-23 22:43:45 -07:00
parent 19b699e015
commit 83941c59d5
2 changed files with 11 additions and 8 deletions

View File

@@ -50,8 +50,12 @@ const getDB = new Promise((resolve, reject) => {
DB.newUser = (userInformation)=>{
return DB.usersCol.insertOne(userInformation).catch((err)=>{
if (err.name === 'MongoError' && err.code === 11000) {
// Duplicate username
return "User already exists";
}
console.log(err);
return false;
return "System Error";
});
};