backend-manager 3.0.25 → 3.0.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.0.25",
3
+ "version": "3.0.28",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  "chalk": "^4.1.2",
40
40
  "cors": "^2.8.5",
41
41
  "dotenv": "^16.3.1",
42
- "firebase-admin": "^11.11.0",
42
+ "firebase-admin": "^11.11.1",
43
43
  "firebase-functions": "^4.5.0",
44
44
  "fs-jetpack": "^5.1.0",
45
45
  "hcaptcha": "^0.1.1",
@@ -57,7 +57,7 @@
57
57
  "npm-api": "^1.0.1",
58
58
  "paypal-server-api": "^1.0.3",
59
59
  "pushid": "^1.0.0",
60
- "resolve-account": "^1.0.5",
60
+ "resolve-account": "^1.0.6",
61
61
  "semver": "^7.5.4",
62
62
  "shortid": "^2.2.16",
63
63
  "sizeitup": "^1.0.7",
@@ -20,8 +20,12 @@ Module.prototype.main = function () {
20
20
  // payload.response.error = new Error(`Failed to delete user: There is an active paid subscription on this account. Please cancel it first and then try deleting the account again.`);
21
21
  // return reject(payload.response.error);
22
22
  // }
23
- const isPlanActive = _.get(user, 'plan.payment.active', null);
24
- if (isPlanActive === true) {
23
+
24
+ // Disallow deleting users with subscriptions in any state other than cancelled or active payments
25
+ if (
26
+ (user?.plan?.status && user?.plan?.status !== 'cancelled')
27
+ || user?.plan?.payment?.active
28
+ ) {
25
29
  // return reject(assistant.errorManager(`Failed to delete user: There is an active paid subscription on this account. Please cancel it first and then try deleting the account again.`, {code: 400, sentry: false, send: false, log: false}).error)
26
30
  // return reject(assistant.errorManager(`This account cannot be deleted until the paid subscription attached to it is cancelled. Please cancel the subscription and then try to delete the account.`, {code: 400, sentry: false, send: false, log: false}).error)
27
31
  return reject(assistant.errorManager(`This account cannot be deleted because it has a paid subscription attached to it. In order to delete the account, you must first cancel the paid subscription.`, {code: 400, sentry: false, send: false, log: false}).error)
@@ -29,13 +29,9 @@ function User(Manager, settings, options) {
29
29
  email: _.get(settings, 'auth.email', null),
30
30
  temporary: _.get(settings, 'auth.temporary', defaults ? false : null),
31
31
  },
32
- roles: {
33
- admin: _.get(settings, 'roles.admin', defaults ? false : null),
34
- betaTester: _.get(settings, 'roles.betaTester', defaults ? false : null),
35
- developer: _.get(settings, 'roles.developer', defaults ? false : null),
36
- },
37
32
  plan: {
38
33
  id: _.get(settings, 'plan.id', defaults ? 'basic' : null), // intro | basic | advanced | premium
34
+ status: _.get(settings, 'plan.status', defaults ? 'cancelled' : null), // active | suspended | cancelled
39
35
  expires: {
40
36
  timestamp: _.get(settings, 'plan.expires.timestamp', defaults ? oldDate : null),
41
37
  timestampUNIX: _.get(settings, 'plan.expires.timestampUNIX', defaults ? oldDateUNIX : null),
@@ -55,11 +51,11 @@ function User(Manager, settings, options) {
55
51
  orderId: _.get(settings, 'plan.payment.orderId', null), // xxx-xxx-xxx
56
52
  resourceId: _.get(settings, 'plan.payment.resourceId', null), // x-xxxxxx
57
53
  frequency: _.get(settings, 'plan.payment.frequency', null), // monthly || annually
54
+ active: _.get(settings, 'plan.payment.active', defaults ? false : null), // true | false
58
55
  startDate: {
59
56
  timestamp: _.get(settings, 'plan.payment.startDate.timestamp', defaults ? now : null), // x-xxxxxx
60
57
  timestampUNIX: _.get(settings, 'plan.payment.startDate.timestampUNIX', defaults ? nowUNIX : null), // x-xxxxxx
61
58
  },
62
- active: _.get(settings, 'plan.payment.active', defaults ? false : null), // true | false
63
59
  updatedBy: {
64
60
  event: {
65
61
  name: _.get(settings, 'plan.payment.updatedBy.event.name', null), // x-xxxxxx
@@ -72,9 +68,14 @@ function User(Manager, settings, options) {
72
68
  },
73
69
  }
74
70
  },
71
+ roles: {
72
+ admin: _.get(settings, 'roles.admin', defaults ? false : null),
73
+ betaTester: _.get(settings, 'roles.betaTester', defaults ? false : null),
74
+ developer: _.get(settings, 'roles.developer', defaults ? false : null),
75
+ },
75
76
  affiliate: {
76
77
  code: _.get(settings, 'affiliate.code', defaults ? shortid.generate() : null),
77
- referrals: [],
78
+ referrals: _.get(settings, 'affiliate.referrals', []),
78
79
  referrer: _.get(settings, 'affiliate.referrer', null),
79
80
  },
80
81
  activity: {