fix(patch email): findOne instead of find

This commit is contained in:
Josepablo C
2024-04-18 10:09:29 -06:00
parent 49673d811c
commit 3819508342

View File

@@ -121,7 +121,7 @@ async function patchUserData( id , data ){
const user = await usersModel.findById( id , { password : 0 , session_token : 0 , session_token_exp : 0 } );
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 ){
throw "email already exists, please choose other";
}