backend-manager 3.2.53 → 3.2.55

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.2.53",
3
+ "version": "3.2.55",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -12,6 +12,7 @@
12
12
  "test": "./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
13
13
  "test:usage": "./node_modules/mocha/bin/mocha test/usage.js --timeout=10000",
14
14
  "test:payment-resolver": "./node_modules/mocha/bin/mocha test/payment-resolver.js --timeout=10000",
15
+ "test:user": "./node_modules/mocha/bin/mocha test/user.js --timeout=10000",
15
16
  "start": "node src/index.js"
16
17
  },
17
18
  "engines": {
@@ -24,6 +24,13 @@ Module.prototype.main = function () {
24
24
  return reject(assistant.errorify(`Path parameter required.`, {code: 400}));
25
25
  }
26
26
 
27
+ // Fix path
28
+ if (payload.data.payload.path.match(/\{pushId\}/)) {
29
+ payload.data.payload.path = payload.data.payload.path.replace(/\{pushId\}/ig, require('pushid')());
30
+ } else if (payload.data.payload.path.match(/\{nanoId\}/)) {
31
+ payload.data.payload.path = payload.data.payload.path.replace(/\{nanoId\}/ig, Manager.Utilities().randomId());
32
+ }
33
+
27
34
  // Set metadata
28
35
  payload.data.payload.document.metadata = Manager.Metadata().set({tag: payload.data.payload.options.metadataTag})
29
36
 
@@ -42,13 +42,6 @@ let Module = {
42
42
  options.options = options.options || {};
43
43
  options.options.merge = typeof options.options.merge === 'undefined' ? true : options.options.merge;
44
44
 
45
- // Fix path
46
- if (options.path.match(/\{pushId\}/)) {
47
- options.path = options.path.replace(/\{pushId\}/ig, require('pushid')());
48
- } else if (options.path.match(/\{nanoId\}/)) {
49
- options.path = options.path.replace(/\{nanoId\}/ig, Manager.Utilities().randomId());
50
- }
51
-
52
45
  if (!user.roles.admin) {
53
46
  response.status = 401;
54
47
  response.error = new Error('Unauthenticated, admin required.');
@@ -74,7 +74,7 @@ function User(Manager, settings, options) {
74
74
  developer: _.get(settings, 'roles.developer', defaults ? false : null),
75
75
  },
76
76
  affiliate: {
77
- code: _.get(settings, 'affiliate.code', defaults ? shortid.generate() : null),
77
+ code: _.get(settings, 'affiliate.code', defaults ? self.Manager.Utilities().randomId({size: 7}) : null),
78
78
  referrals: _.get(settings, 'affiliate.referrals', []),
79
79
  referrer: _.get(settings, 'affiliate.referrer', null),
80
80
  },