diff --git a/src/lib/Handlers/Account/index.js b/src/lib/Handlers/Account/index.js index 862acca..939c448 100644 --- a/src/lib/Handlers/Account/index.js +++ b/src/lib/Handlers/Account/index.js @@ -78,9 +78,7 @@ async function login_with_session_token( session_token ){ async function complete_register( userId , data ){ let { - company_type, - company_name, - company_description, + company_type } = data; let permissions; @@ -93,6 +91,7 @@ async function complete_register( userId , data ){ }else{ throw "Invalid company type"; } + data.company_type = company_type; const user = await UserModel.findById( userId , { password : 0 , session_token : 0 , session_token_exp : 0 } ); @@ -100,11 +99,7 @@ async function complete_register( userId , data ){ throw "User already register"; } - const company = new companiesModels( { - company_type, - company_name, - company_description, - } ); + const company = new companiesModels( data ); await company.save(); diff --git a/src/lib/Handlers/Users.handler.js b/src/lib/Handlers/Users.handler.js index 16ed6fb..b9309db 100644 --- a/src/lib/Handlers/Users.handler.js +++ b/src/lib/Handlers/Users.handler.js @@ -119,7 +119,7 @@ async function patchUserData( id , data ){ const user = await usersModel.findById( id , { password : 0 , session_token : 0 , session_token_exp : 0 } ); - if( data.email !== user.email ){ + if( (data.email) && (data.email !== user.email) ){ const user_already_exists = await usersModel.find({ email : data.email }); if( user_already_exists ){ throw "email already exists, please choose other";