@xuda.io/account_module 1.2.1077 → 1.2.1079
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +4 -59
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2475,69 +2475,14 @@ export const update_account_profile = async function (req, job_id, headers) {
|
|
|
2475
2475
|
const account_profile_properties = ['profile_name', 'profile_signature', 'profile_email', 'profile_picture', 'profile_avatar', 'profile_picture_obj', 'profile_avatar_obj'];
|
|
2476
2476
|
try {
|
|
2477
2477
|
let { data: acc_obj } = await db_module.get_couch_doc('xuda_accounts', uid);
|
|
2478
|
-
|
|
2478
|
+
let changes_arr = [];
|
|
2479
2479
|
for (const key of account_profile_properties) {
|
|
2480
2480
|
let val = data[key];
|
|
2481
2481
|
if (typeof val === 'undefined') continue;
|
|
2482
|
-
if (
|
|
2483
|
-
|
|
2484
|
-
account_info_changes_arr.push(key);
|
|
2485
|
-
|
|
2486
|
-
if (key === 'profile_picture') {
|
|
2487
|
-
if (account_obj.account_info['profile_picture'].includes('googleusercontent')) {
|
|
2488
|
-
account_obj.account_info['profile_picture_google'] = val;
|
|
2489
|
-
} else {
|
|
2490
|
-
//delete old profile picture
|
|
2491
|
-
// const profile_picture = path.basename(account_obj?.account_info?.['profile_picture'] || '');
|
|
2492
|
-
// if (profile_picture) {
|
|
2493
|
-
// drive_module.delete_drive_files({ uid, drive_type: 'user', files_arr: [profile_picture] });
|
|
2494
|
-
// }
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
const profile_avatar_obj = account_obj?.account_info?.profile_avatar_obj || '';
|
|
2498
|
-
if (profile_avatar_obj) {
|
|
2499
|
-
drive_module.delete_drive_files({ uid, drive_type: 'user', files_arr: [{ type: 'file', file_path: path.join(profile_avatar_obj.file_path, profile_avatar_obj.filename) }] });
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2482
|
+
if (acc_obj[key] !== val) {
|
|
2483
|
+
changes_arr.push(key);
|
|
2502
2484
|
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
if (account_obj.account_info.account_type === 'business') {
|
|
2506
|
-
if (key === 'business_name' && validate_input(val, 150, true, false) < 0) {
|
|
2507
|
-
error[key] = 'Invalid business name';
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
if (key === 'first_name' && !validate_input(val, 35, true, false)) {
|
|
2511
|
-
// print_r(validate_input($val, 35, true, false)<0);
|
|
2512
|
-
// exit;
|
|
2513
|
-
error[key] = 'Invalid first name';
|
|
2514
|
-
}
|
|
2515
|
-
if (key === 'last_name' && !validate_input(val, 35, true, false)) {
|
|
2516
|
-
error[key] = 'Invalid last name';
|
|
2517
|
-
}
|
|
2518
|
-
if (key === 'email' && (!validator.isEmail(val) || !val || val.length < 2)) {
|
|
2519
|
-
error[key] = 'Invalid email';
|
|
2520
|
-
}
|
|
2521
|
-
// if (key === 'phone_number' && (!/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/.test(val) || !val || val.length < 2)) {
|
|
2522
|
-
// // if (key === "phone_number" && (!preg_match("/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/", $val) || !$val || count($val) < 2)) {
|
|
2523
|
-
// error[key] = 'Invalid phone number';
|
|
2524
|
-
// }
|
|
2525
|
-
if (key === 'address' && !/^[a-z0-9- ]+$/i.test(val)) {
|
|
2526
|
-
// if (key === "address" && !preg_match('/^[a-z0-9- ]+$/i', $val)) {
|
|
2527
|
-
error[key] = 'Invalid address';
|
|
2528
|
-
}
|
|
2529
|
-
if (key === 'city' && !validate_input(val, 255, false, false)) {
|
|
2530
|
-
error[key] = 'Invalid city';
|
|
2531
|
-
}
|
|
2532
|
-
if (key === 'state' && !validate_input(val, 50, false, false)) {
|
|
2533
|
-
error[key] = 'Invalid state';
|
|
2534
|
-
}
|
|
2535
|
-
if (key === 'zip' && validate_input(val, 9, false, false) < 0) {
|
|
2536
|
-
error[key] = 'Invalid zip';
|
|
2537
|
-
}
|
|
2538
|
-
if (key === 'country' && !validate_input(val, 55, false, false)) {
|
|
2539
|
-
error[key] = 'Invalid country';
|
|
2540
|
-
}
|
|
2485
|
+
acc_obj[key] = val;
|
|
2541
2486
|
}
|
|
2542
2487
|
}
|
|
2543
2488
|
|