@xuda.io/account_module 1.2.1078 → 1.2.1080

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.
Files changed (2) hide show
  1. package/index.mjs +4 -56
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2480,66 +2480,14 @@ export const update_account_profile = async function (req, job_id, headers) {
2480
2480
  let val = data[key];
2481
2481
  if (typeof val === 'undefined') continue;
2482
2482
  if (acc_obj[key] !== val) {
2483
- account_info_changes_arr.push(key);
2484
-
2485
- if (key === 'profile_picture') {
2486
- if (account_obj.account_info['profile_picture'].includes('googleusercontent')) {
2487
- account_obj.account_info['profile_picture_google'] = val;
2488
- } else {
2489
- //delete old profile picture
2490
- // const profile_picture = path.basename(account_obj?.account_info?.['profile_picture'] || '');
2491
- // if (profile_picture) {
2492
- // drive_module.delete_drive_files({ uid, drive_type: 'user', files_arr: [profile_picture] });
2493
- // }
2494
- }
2495
-
2496
- const profile_avatar_obj = account_obj?.account_info?.profile_avatar_obj || '';
2497
- if (profile_avatar_obj) {
2498
- 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) }] });
2499
- }
2500
- }
2501
-
2502
- account_obj.account_info[key] = val;
2483
+ changes_arr.push(key);
2503
2484
 
2504
- if (account_obj.account_info.account_type === 'business') {
2505
- if (key === 'business_name' && validate_input(val, 150, true, false) < 0) {
2506
- error[key] = 'Invalid business name';
2507
- }
2508
- }
2509
- if (key === 'first_name' && !validate_input(val, 35, true, false)) {
2510
- // print_r(validate_input($val, 35, true, false)<0);
2511
- // exit;
2512
- error[key] = 'Invalid first name';
2513
- }
2514
- if (key === 'last_name' && !validate_input(val, 35, true, false)) {
2515
- error[key] = 'Invalid last name';
2516
- }
2517
- if (key === 'email' && (!validator.isEmail(val) || !val || val.length < 2)) {
2518
- error[key] = 'Invalid email';
2519
- }
2520
- // if (key === 'phone_number' && (!/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/.test(val) || !val || val.length < 2)) {
2521
- // // if (key === "phone_number" && (!preg_match("/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/", $val) || !$val || count($val) < 2)) {
2522
- // error[key] = 'Invalid phone number';
2523
- // }
2524
- if (key === 'address' && !/^[a-z0-9- ]+$/i.test(val)) {
2525
- // if (key === "address" && !preg_match('/^[a-z0-9- ]+$/i', $val)) {
2526
- error[key] = 'Invalid address';
2527
- }
2528
- if (key === 'city' && !validate_input(val, 255, false, false)) {
2529
- error[key] = 'Invalid city';
2530
- }
2531
- if (key === 'state' && !validate_input(val, 50, false, false)) {
2532
- error[key] = 'Invalid state';
2533
- }
2534
- if (key === 'zip' && validate_input(val, 9, false, false) < 0) {
2535
- error[key] = 'Invalid zip';
2536
- }
2537
- if (key === 'country' && !validate_input(val, 55, false, false)) {
2538
- error[key] = 'Invalid country';
2539
- }
2485
+ acc_obj[key] = val;
2540
2486
  }
2541
2487
  }
2542
2488
 
2489
+ if(changes_arr.length)
2490
+
2543
2491
  const d = Date.now();
2544
2492
  const doc = {
2545
2493
  _id: await _common.xuda_get_uuid('contact_profile'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1078",
3
+ "version": "1.2.1080",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {