fix(accunt/user): Fix complete register process and profile patch

This commit is contained in:
Josepablo C
2024-03-11 02:11:37 -06:00
parent 11ca8da4c8
commit 8ed07c5ca5
2 changed files with 4 additions and 9 deletions

View File

@@ -78,9 +78,7 @@ async function login_with_session_token( session_token ){
async function complete_register( userId , data ){ async function complete_register( userId , data ){
let { let {
company_type, company_type
company_name,
company_description,
} = data; } = data;
let permissions; let permissions;
@@ -93,6 +91,7 @@ async function complete_register( userId , data ){
}else{ }else{
throw "Invalid company type"; throw "Invalid company type";
} }
data.company_type = company_type;
const user = await UserModel.findById( userId , { password : 0 , session_token : 0 , session_token_exp : 0 } ); 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"; throw "User already register";
} }
const company = new companiesModels( { const company = new companiesModels( data );
company_type,
company_name,
company_description,
} );
await company.save(); await company.save();

View File

@@ -119,7 +119,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 !== 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.find({ 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";