fix(accunt/user): Fix complete register process and profile patch
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user