fix(patch email): findOne instead of find
This commit is contained in:
@@ -121,7 +121,7 @@ async function patchUserData( id , data ){
|
|||||||
const user = await usersModel.findById( id , { password : 0 , session_token : 0 , session_token_exp : 0 } );
|
const user = await usersModel.findById( id , { password : 0 , session_token : 0 , session_token_exp : 0 } );
|
||||||
|
|
||||||
if( (data.email) && (data.email !== user.email) ){
|
if( (data.email) && (data.email !== user.email) ){
|
||||||
const user_already_exists = await usersModel.find({ email : data.email });
|
const user_already_exists = await usersModel.findOne({ email : data.email });
|
||||||
if( user_already_exists ){
|
if( user_already_exists ){
|
||||||
throw "email already exists, please choose other";
|
throw "email already exists, please choose other";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user