return error when register user with used email:
This commit is contained in:
@@ -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";
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user