backend-manager 3.2.31 → 3.2.33
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/manager/functions/core/actions/api/admin/backup.js +3 -3
- package/src/manager/functions/core/actions/api/admin/create-post.js +3 -3
- package/src/manager/functions/core/actions/api/admin/cron.js +3 -3
- package/src/manager/functions/core/actions/api/admin/database-read.js +2 -2
- package/src/manager/functions/core/actions/api/admin/database-write.js +3 -3
- package/src/manager/functions/core/actions/api/admin/firestore-query.js +2 -2
- package/src/manager/functions/core/actions/api/admin/firestore-read.js +3 -3
- package/src/manager/functions/core/actions/api/admin/firestore-write.js +3 -3
- package/src/manager/functions/core/actions/api/admin/get-stats.js +4 -4
- package/src/manager/functions/core/actions/api/admin/payment-processor.js +3 -3
- package/src/manager/functions/core/actions/api/admin/send-notification.js +4 -4
- package/src/manager/functions/core/actions/api/admin/sync-users.js +2 -2
- package/src/manager/functions/core/actions/api/firebase/get-providers.js +4 -4
- package/src/manager/functions/core/actions/api/general/generate-uuid.js +2 -2
- package/src/manager/functions/core/actions/api/general/send-email.js +5 -5
- package/src/manager/functions/core/actions/api/handler/create-post.js +3 -3
- package/src/manager/functions/core/actions/api/special/setup-electron-manager-client.js +3 -3
- package/src/manager/functions/core/actions/api/template.js +1 -1
- package/src/manager/functions/core/actions/api/test/create-test-accounts.js +1 -1
- package/src/manager/functions/core/actions/api/test/webhook.js +1 -1
- package/src/manager/functions/core/actions/api/user/create-custom-token.js +1 -1
- package/src/manager/functions/core/actions/api/user/delete.js +2 -2
- package/src/manager/functions/core/actions/api/user/get-active-sessions.js +1 -1
- package/src/manager/functions/core/actions/api/user/regenerate-api-keys.js +1 -1
- package/src/manager/functions/core/actions/api/user/sign-out-all-sessions.js +3 -3
- package/src/manager/functions/core/actions/api/user/sign-up copy.js +544 -0
- package/src/manager/functions/core/actions/api/user/sign-up.js +58 -501
- package/src/manager/functions/core/actions/api/user/submit-feedback.js +2 -2
- package/src/manager/functions/core/actions/api/user/validate-settings.js +2 -2
- package/src/manager/functions/core/actions/api.js +4 -4
- package/src/manager/functions/core/cron/daily/reset-usage.js +33 -9
- package/src/manager/functions/core/cron/daily.js +1 -1
- package/src/manager/functions/core/events/auth/on-create copy.js +121 -0
- package/src/manager/functions/core/events/auth/on-create.js +476 -27
- package/src/manager/helpers/assistant.js +19 -7
- package/src/manager/helpers/middleware.js +9 -11
- package/src/manager/helpers/settings.js +2 -2
- package/src/manager/helpers/usage.js +10 -10
- package/src/manager/index.js +1 -1
- package/src/manager/libraries/openai.js +22 -13
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
15
15
|
- `Security` in case of vulnerabilities.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
|
+
## [3.2.32] - 2023-01-30
|
|
19
|
+
### Added
|
|
20
|
+
- Modified `.assistant().errorify()` to have defaults of `log`, `sentry`, and `send` to `false` if not specified to prevent accidental logging and premature sending of errors.
|
|
21
|
+
|
|
18
22
|
## [3.2.30] - 2023-01-30
|
|
19
23
|
### Added
|
|
20
24
|
- Modified `.assistant()` token/key check to use `options.apiKey || data.apiKey`
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ Module.prototype.main = function () {
|
|
|
19
19
|
payload.data.payload.deletionRegex = payload.data.payload.deletionRegex ? powertools.regexify(payload.data.payload.deletionRegex) : payload.data.payload.deletionRegex;
|
|
20
20
|
|
|
21
21
|
if (!payload.user.roles.admin && assistant.isProduction()) {
|
|
22
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
22
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// https://googleapis.dev/nodejs/firestore/latest/v1.FirestoreAdminClient.html#exportDocuments
|
|
@@ -62,7 +62,7 @@ Module.prototype.main = function () {
|
|
|
62
62
|
.catch(async (e) => {
|
|
63
63
|
await self._setMetaStats(e);
|
|
64
64
|
|
|
65
|
-
return reject(assistant.errorify(e, {code: 500
|
|
65
|
+
return reject(assistant.errorify(e, {code: 500}));
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
});
|
|
@@ -97,7 +97,7 @@ Module.prototype._setMetaStats = function (error, meta) {
|
|
|
97
97
|
metadata: Manager.Metadata().set({tag: 'admin:backup'}),
|
|
98
98
|
}, {merge: true})
|
|
99
99
|
.catch(e => {
|
|
100
|
-
assistant.errorify(e, {code: 500,
|
|
100
|
+
assistant.errorify(e, {code: 500, log: true});
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
return resolve();
|
|
@@ -18,7 +18,7 @@ Module.prototype.main = function () {
|
|
|
18
18
|
return new Promise(async function(resolve, reject) {
|
|
19
19
|
// Perform checks
|
|
20
20
|
if (!payload.user.roles.admin && !payload.user.roles.blogger) {
|
|
21
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
21
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const repoInfo = assistant.parseRepo(get(self.Manager.config, 'github.repo_website'));
|
|
@@ -45,7 +45,7 @@ Module.prototype.main = function () {
|
|
|
45
45
|
const finalPost = await poster.create(payload.data).catch(e => e);
|
|
46
46
|
|
|
47
47
|
if (finalPost instanceof Error) {
|
|
48
|
-
return reject(assistant.errorify(`Failed to post: ${finalPost}`, {code: 500
|
|
48
|
+
return reject(assistant.errorify(`Failed to post: ${finalPost}`, {code: 500}));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// Request indexing
|
|
@@ -68,7 +68,7 @@ Module.prototype.main = function () {
|
|
|
68
68
|
return resolve({data: finalPost});
|
|
69
69
|
})
|
|
70
70
|
.catch((e) => {
|
|
71
|
-
return reject(assistant.errorify(`Failed to post: ${e}`, {code: 500
|
|
71
|
+
return reject(assistant.errorify(`Failed to post: ${e}`, {code: 500}));
|
|
72
72
|
})
|
|
73
73
|
|
|
74
74
|
});
|
|
@@ -13,12 +13,12 @@ Module.prototype.main = function () {
|
|
|
13
13
|
|
|
14
14
|
// Check if the user is an admin
|
|
15
15
|
if (!payload.user.roles.admin && assistant.isProduction()) {
|
|
16
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
16
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Check if the ID is set
|
|
20
20
|
if (!payload.data.payload.id) {
|
|
21
|
-
return reject(assistant.errorify(`Missing parameter {id}`, {code: 400
|
|
21
|
+
return reject(assistant.errorify(`Missing parameter {id}`, {code: 400}));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Run the cron job
|
|
@@ -27,7 +27,7 @@ Module.prototype.main = function () {
|
|
|
27
27
|
return resolve({data: res});
|
|
28
28
|
})
|
|
29
29
|
.catch(e => {
|
|
30
|
-
return reject(assistant.errorify(e, {code: 400
|
|
30
|
+
return reject(assistant.errorify(e, {code: 400}));
|
|
31
31
|
})
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -16,9 +16,9 @@ Module.prototype.main = function () {
|
|
|
16
16
|
|
|
17
17
|
// Perform checks
|
|
18
18
|
if (!payload.user.roles.admin) {
|
|
19
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
19
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
20
20
|
} else if (!payload.data.payload.path) {
|
|
21
|
-
return reject(assistant.errorify(`<path> parameter required`, {code: 400
|
|
21
|
+
return reject(assistant.errorify(`<path> parameter required`, {code: 400}));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Read from Firestore
|
|
@@ -17,9 +17,9 @@ Module.prototype.main = function () {
|
|
|
17
17
|
|
|
18
18
|
// Perform checks
|
|
19
19
|
if (payload.user.roles.admin) {
|
|
20
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
20
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
21
21
|
} else if (!payload.data.payload.path) {
|
|
22
|
-
return reject(assistant.errorify(`<path> parameter required`, {code: 400
|
|
22
|
+
return reject(assistant.errorify(`<path> parameter required`, {code: 400}));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Write to Firestore
|
|
@@ -29,7 +29,7 @@ Module.prototype.main = function () {
|
|
|
29
29
|
return resolve({data: payload.data.payload.document});
|
|
30
30
|
})
|
|
31
31
|
.catch((e) => {
|
|
32
|
-
return reject(assistant.errorify(e, {code: 500
|
|
32
|
+
return reject(assistant.errorify(e, {code: 500}));
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -15,7 +15,7 @@ Module.prototype.main = function () {
|
|
|
15
15
|
return new Promise(async function(resolve, reject) {
|
|
16
16
|
// Perform checks
|
|
17
17
|
if (!payload.user.roles.admin) {
|
|
18
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
18
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Run queries
|
|
@@ -35,7 +35,7 @@ Module.prototype.main = function () {
|
|
|
35
35
|
return resolve({data: self.docs});
|
|
36
36
|
})
|
|
37
37
|
.catch((e) => {
|
|
38
|
-
return reject(assistant.errorify(e, {code: 500
|
|
38
|
+
return reject(assistant.errorify(e, {code: 500}));
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
});
|
|
@@ -16,9 +16,9 @@ Module.prototype.main = function () {
|
|
|
16
16
|
|
|
17
17
|
// Perform checks
|
|
18
18
|
if (!payload.user.roles.admin) {
|
|
19
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
19
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
20
20
|
} else if (!payload.data.payload.path) {
|
|
21
|
-
return reject(assistant.errorify(`<path> parameter required`, {code: 400
|
|
21
|
+
return reject(assistant.errorify(`<path> parameter required`, {code: 400}));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Read from Firestore
|
|
@@ -28,7 +28,7 @@ Module.prototype.main = function () {
|
|
|
28
28
|
return resolve({data: doc.data()});
|
|
29
29
|
})
|
|
30
30
|
.catch(e => {
|
|
31
|
-
return reject(assistant.errorify(e, {code: 500
|
|
31
|
+
return reject(assistant.errorify(e, {code: 500}));
|
|
32
32
|
})
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -19,9 +19,9 @@ Module.prototype.main = function () {
|
|
|
19
19
|
|
|
20
20
|
// Perform checks
|
|
21
21
|
if (!payload.user.roles.admin) {
|
|
22
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
22
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
23
23
|
} else if (!payload.data.payload.path) {
|
|
24
|
-
return reject(assistant.errorify(`Path parameter required.`, {code: 400
|
|
24
|
+
return reject(assistant.errorify(`Path parameter required.`, {code: 400}));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Set metadata
|
|
@@ -37,7 +37,7 @@ Module.prototype.main = function () {
|
|
|
37
37
|
return resolve({data: {path: payload.data.payload.path}});
|
|
38
38
|
})
|
|
39
39
|
.catch(e => {
|
|
40
|
-
return reject(assistant.errorify(e, {code: 500
|
|
40
|
+
return reject(assistant.errorify(e, {code: 500}));
|
|
41
41
|
})
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -17,7 +17,7 @@ Module.prototype.main = function () {
|
|
|
17
17
|
|
|
18
18
|
// Perform checks
|
|
19
19
|
if (!payload.user.roles.admin) {
|
|
20
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
20
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Get stats
|
|
@@ -34,7 +34,7 @@ Module.prototype.main = function () {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (data instanceof Error) {
|
|
37
|
-
return reject(assistant.errorify(data, {code: 500
|
|
37
|
+
return reject(assistant.errorify(data, {code: 500}));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Retrieve the stats again after updating
|
|
@@ -47,13 +47,13 @@ Module.prototype.main = function () {
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
if (data instanceof Error) {
|
|
50
|
-
return reject(assistant.errorify(data, {code: 500
|
|
50
|
+
return reject(assistant.errorify(data, {code: 500}));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return resolve({data: data})
|
|
54
54
|
})
|
|
55
55
|
.catch(function (e) {
|
|
56
|
-
return reject(assistant.errorify(`Failed to get: ${e}`, {code: 500
|
|
56
|
+
return reject(assistant.errorify(`Failed to get: ${e}`, {code: 500}));
|
|
57
57
|
})
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -15,12 +15,12 @@ Module.prototype.main = function () {
|
|
|
15
15
|
return new Promise(async function(resolve, reject) {
|
|
16
16
|
|
|
17
17
|
if (!payload.user.roles.admin) {
|
|
18
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
18
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const productId = _.get(payload, 'data.payload.payload.details.productIdGlobal');
|
|
22
22
|
if (!productId) {
|
|
23
|
-
return reject(assistant.errorify(`No productId`, {code: 400
|
|
23
|
+
return reject(assistant.errorify(`No productId`, {code: 400}));
|
|
24
24
|
}
|
|
25
25
|
const processorPath = `${process.cwd()}/payment-processors/${productId}.js`
|
|
26
26
|
let processor;
|
|
@@ -45,7 +45,7 @@ Module.prototype.main = function () {
|
|
|
45
45
|
return resolve({data: result});
|
|
46
46
|
})
|
|
47
47
|
.catch(e => {
|
|
48
|
-
return reject(assistant.errorify(`Payment processor @ "${processorPath}" failed: ${e}`, {code: 400, sentry: true
|
|
48
|
+
return reject(assistant.errorify(`Payment processor @ "${processorPath}" failed: ${e}`, {code: 400, sentry: true}));
|
|
49
49
|
})
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -37,17 +37,17 @@ Module.prototype.main = function () {
|
|
|
37
37
|
self._notificationPayload.notification.click_action.searchParams.set('cb', new Date().getTime())
|
|
38
38
|
self._notificationPayload.notification.click_action = self._notificationPayload.notification.click_action.toString()
|
|
39
39
|
} catch (e) {
|
|
40
|
-
assistant.errorify(`Failed to add cb to URL: ${e}`, {code: 500,
|
|
40
|
+
assistant.errorify(`Failed to add cb to URL: ${e}`, {code: 500, log: true});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
assistant.log('Resolved notification payload', self._notificationPayload)
|
|
44
44
|
|
|
45
45
|
if (!payload.user.roles.admin) {
|
|
46
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
46
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (!payload.data.payload.title || !payload.data.payload.body) {
|
|
50
|
-
return reject(assistant.errorify(`Parameters <title> and <body> required`, {code: 400, sentry: true
|
|
50
|
+
return reject(assistant.errorify(`Parameters <title> and <body> required`, {code: 400, sentry: true}));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
await self.getTokens({tags: false})
|
|
@@ -55,7 +55,7 @@ Module.prototype.main = function () {
|
|
|
55
55
|
return resolve({data: payload.response.data})
|
|
56
56
|
})
|
|
57
57
|
.catch(e => {
|
|
58
|
-
return reject(assistant.errorify(`Failed to send notification: ${e}`, {code: 400, sentry: true
|
|
58
|
+
return reject(assistant.errorify(`Failed to send notification: ${e}`, {code: 400, sentry: true}));
|
|
59
59
|
})
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -15,7 +15,7 @@ Module.prototype.main = function () {
|
|
|
15
15
|
|
|
16
16
|
// If the user is not an admin, reject
|
|
17
17
|
if (!payload.user.roles.admin && assistant.isProduction()) {
|
|
18
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
18
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Get lastPageToken from meta/stats
|
|
@@ -116,7 +116,7 @@ Module.prototype.main = function () {
|
|
|
116
116
|
return resolve();
|
|
117
117
|
})
|
|
118
118
|
.catch(e => {
|
|
119
|
-
return reject(assistant.errorify(e, {code: 500
|
|
119
|
+
return reject(assistant.errorify(e, {code: 500}));
|
|
120
120
|
})
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -44,7 +44,7 @@ Module.prototype.main = function () {
|
|
|
44
44
|
payload.data.payload.firebaseApiKey = payload.data.payload.firebaseApiKey || _.get(Manager, 'config.firebaseConfig.apiKey') || false;
|
|
45
45
|
|
|
46
46
|
if (!payload.data.payload.firebaseApiKey) {
|
|
47
|
-
return reject(assistant.errorify(`The firebaseApiKey parameter is required.`, {code: 400
|
|
47
|
+
return reject(assistant.errorify(`The firebaseApiKey parameter is required.`, {code: 400}));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Default
|
|
@@ -91,7 +91,7 @@ Module.prototype.main = function () {
|
|
|
91
91
|
|
|
92
92
|
payload.response.data[provider.name] = result;
|
|
93
93
|
} catch (e) {
|
|
94
|
-
assistant.errorify(`Error parsing error: ${e}`, {
|
|
94
|
+
assistant.errorify(`Error parsing error: ${e}`, {code: 500, sentry: true});
|
|
95
95
|
payload.response.data[provider.name] = false;
|
|
96
96
|
}
|
|
97
97
|
})
|
|
@@ -136,7 +136,7 @@ Module.prototype.main = function () {
|
|
|
136
136
|
|
|
137
137
|
})
|
|
138
138
|
.catch(e => {
|
|
139
|
-
assistant.errorify(`Error getting app data: ${e}`, {
|
|
139
|
+
assistant.errorify(`Error getting app data: ${e}`, {code: 500, log: true})
|
|
140
140
|
})
|
|
141
141
|
.finally(r => {
|
|
142
142
|
return resolve({data: payload.response.data});
|
|
@@ -144,7 +144,7 @@ Module.prototype.main = function () {
|
|
|
144
144
|
|
|
145
145
|
})
|
|
146
146
|
.catch(e => {
|
|
147
|
-
return reject(assistant.errorify(`Failed to check providers: ${e}`, {code: 500
|
|
147
|
+
return reject(assistant.errorify(`Failed to check providers: ${e}`, {code: 500}));
|
|
148
148
|
})
|
|
149
149
|
|
|
150
150
|
});
|
|
@@ -20,14 +20,14 @@ Module.prototype.main = function () {
|
|
|
20
20
|
|
|
21
21
|
if (payload.data.payload.version === '5') {
|
|
22
22
|
if (!payload.data.payload.name) {
|
|
23
|
-
return reject(assistant.errorify(`You must provide a name to hash for uuid v5.`, {code: 400
|
|
23
|
+
return reject(assistant.errorify(`You must provide a name to hash for uuid v5.`, {code: 400}));
|
|
24
24
|
} else {
|
|
25
25
|
result = uuid.v5(payload.data.payload.name, payload.data.payload.namespace);
|
|
26
26
|
}
|
|
27
27
|
} else if (payload.data.payload.version === '4') {
|
|
28
28
|
result = uuid.v4();
|
|
29
29
|
} else {
|
|
30
|
-
return reject(assistant.errorify(`v${payload.data.payload.version} is not a valid version.`, {code: 400
|
|
30
|
+
return reject(assistant.errorify(`v${payload.data.payload.version} is not a valid version.`, {code: 400}));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
assistant.log('UUID Generated', payload.data.payload, result);
|
|
@@ -32,9 +32,9 @@ Module.prototype.main = function () {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (!payload.data.payload.id) {
|
|
35
|
-
return reject(assistant.errorify(`Parameter {id} is required.`, {code: 400
|
|
35
|
+
return reject(assistant.errorify(`Parameter {id} is required.`, {code: 400}));
|
|
36
36
|
} else if (!payload.data.payload.email) {
|
|
37
|
-
return reject(assistant.errorify(`Parameter {email} is required.`, {code: 400
|
|
37
|
+
return reject(assistant.errorify(`Parameter {email} is required.`, {code: 400}));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
let emailPayload
|
|
@@ -46,7 +46,7 @@ Module.prototype.main = function () {
|
|
|
46
46
|
script(payload.data.payload, Manager.config),
|
|
47
47
|
);
|
|
48
48
|
} catch (e) {
|
|
49
|
-
return reject(assistant.errorify(`${payload.data.payload.id} is not a valid email ID.`, {code: 400
|
|
49
|
+
return reject(assistant.errorify(`${payload.data.payload.id} is not a valid email ID.`, {code: 400}));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const storage = Manager.storage({temporary: true});
|
|
@@ -70,7 +70,7 @@ Module.prototype.main = function () {
|
|
|
70
70
|
assistant.log('Storage:', storage.getState()['api:general:send-email']);
|
|
71
71
|
|
|
72
72
|
if (ipData.count >= emailPayload.spamFilter.ip || emailData.count >= emailPayload.spamFilter.email) {
|
|
73
|
-
self.assistant.errorify(`Spam filter triggered ip=${ipData.count}, email=${emailData.count}`, {code: 429,
|
|
73
|
+
self.assistant.errorify(`Spam filter triggered ip=${ipData.count}, email=${emailData.count}`, {code: 429, log: true});
|
|
74
74
|
|
|
75
75
|
return resolve({data: {success: true}});
|
|
76
76
|
}
|
|
@@ -100,7 +100,7 @@ Module.prototype.main = function () {
|
|
|
100
100
|
});
|
|
101
101
|
})
|
|
102
102
|
.catch(e => {
|
|
103
|
-
return reject(assistant.errorify(`Error sending email: ${e}`, {code: 500, sentry: true
|
|
103
|
+
return reject(assistant.errorify(`Error sending email: ${e}`, {code: 500, sentry: true}));
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
});
|
|
@@ -15,7 +15,7 @@ Module.prototype.main = function () {
|
|
|
15
15
|
return new Promise(async function(resolve, reject) {
|
|
16
16
|
|
|
17
17
|
if (!payload.user.roles.admin) {
|
|
18
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
18
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
payload.response.data = {
|
|
@@ -83,7 +83,7 @@ Module.prototype.main = function () {
|
|
|
83
83
|
.catch(e => e);
|
|
84
84
|
|
|
85
85
|
if (createdInvoice instanceof Error) {
|
|
86
|
-
return reject(assistant.errorify(createdInvoice, {code: 400
|
|
86
|
+
return reject(assistant.errorify(createdInvoice, {code: 400}));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// Send invoice
|
|
@@ -104,7 +104,7 @@ Module.prototype.main = function () {
|
|
|
104
104
|
.catch(e => e);
|
|
105
105
|
|
|
106
106
|
if (sentInvoice instanceof Error) {
|
|
107
|
-
return reject(assistant.errorify(sentInvoice, {code: 500
|
|
107
|
+
return reject(assistant.errorify(sentInvoice, {code: 500}));
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
payload.response.data.invoice = {
|
|
@@ -32,11 +32,11 @@ Module.prototype.main = function () {
|
|
|
32
32
|
signInToken = token;
|
|
33
33
|
})
|
|
34
34
|
.catch(e => {
|
|
35
|
-
error = assistant.errorify(`Failed to create custom token: ${e}`, {code: 500
|
|
35
|
+
error = assistant.errorify(`Failed to create custom token: ${e}`, {code: 500});
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
.catch(e => {
|
|
39
|
-
assistant.errorify(`Failed to resolve user: ${e}`, {code: 500,
|
|
39
|
+
assistant.errorify(`Failed to resolve user: ${e}`, {code: 500, log: true});
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
if (error) {
|
|
@@ -93,7 +93,7 @@ Module.prototype.main = function () {
|
|
|
93
93
|
});
|
|
94
94
|
})
|
|
95
95
|
.catch(e => {
|
|
96
|
-
return reject(assistant.errorify(`Error fetching app details: ${e}`, {code: 500
|
|
96
|
+
return reject(assistant.errorify(`Error fetching app details: ${e}`, {code: 500}));
|
|
97
97
|
})
|
|
98
98
|
|
|
99
99
|
});
|
|
@@ -12,7 +12,7 @@ Module.prototype.main = function () {
|
|
|
12
12
|
return new Promise(async function(resolve, reject) {
|
|
13
13
|
|
|
14
14
|
if (!payload.user.roles.admin) {
|
|
15
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
15
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// self.Api.resolveUser({adminRequired: false})
|
|
@@ -12,7 +12,7 @@ Module.prototype.main = function () {
|
|
|
12
12
|
return new Promise(async function(resolve, reject) {
|
|
13
13
|
|
|
14
14
|
if (!payload.user.roles.admin) {
|
|
15
|
-
return reject(assistant.errorify(`Admin required.`, {code: 401
|
|
15
|
+
return reject(assistant.errorify(`Admin required.`, {code: 401}));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
assistant.log('User:', payload.user);
|
|
@@ -19,7 +19,7 @@ Module.prototype.main = function () {
|
|
|
19
19
|
if (payload.data.payload.status >= 200 && payload.data.payload.status <= 299) {
|
|
20
20
|
return resolve({data: payload.data.payload.response, status: payload.data.payload.status});
|
|
21
21
|
} else if (payload.data.payload.status >= 400 && payload.data.payload.status <= 599) {
|
|
22
|
-
return reject(assistant.errorify(payload.data.payload.response || 'Unknown error message provided', {code: payload.data.payload.status
|
|
22
|
+
return reject(assistant.errorify(payload.data.payload.response || 'Unknown error message provided', {code: payload.data.payload.status}));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
});
|
|
@@ -19,7 +19,7 @@ Module.prototype.main = function () {
|
|
|
19
19
|
return resolve({data: {token: token}});
|
|
20
20
|
})
|
|
21
21
|
.catch(e => {
|
|
22
|
-
return reject(assistant.errorify(`Failed to create custom token: ${e}`, {code: 400
|
|
22
|
+
return reject(assistant.errorify(`Failed to create custom token: ${e}`, {code: 400}));
|
|
23
23
|
})
|
|
24
24
|
})
|
|
25
25
|
.catch(e => {
|
|
@@ -22,7 +22,7 @@ Module.prototype.main = function () {
|
|
|
22
22
|
(user?.plan?.status && user?.plan?.status !== 'cancelled')
|
|
23
23
|
|| user?.plan?.payment?.active
|
|
24
24
|
) {
|
|
25
|
-
return reject(assistant.errorify(`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
|
|
25
|
+
return reject(assistant.errorify(`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}));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Signout of all sessions
|
|
@@ -54,7 +54,7 @@ Module.prototype.main = function () {
|
|
|
54
54
|
return resolve({data: {success: true}});
|
|
55
55
|
})
|
|
56
56
|
.catch(e => {
|
|
57
|
-
return reject(assistant.errorify(`Failed to delete user: ${e}`, {code: 400
|
|
57
|
+
return reject(assistant.errorify(`Failed to delete user: ${e}`, {code: 400}));
|
|
58
58
|
})
|
|
59
59
|
})
|
|
60
60
|
.catch(e => {
|
|
@@ -30,7 +30,7 @@ Module.prototype.main = function () {
|
|
|
30
30
|
return resolve({data: data});
|
|
31
31
|
})
|
|
32
32
|
.catch(e => {
|
|
33
|
-
return reject(assistant.errorify(`Session query error: ${e}`, {code: 500
|
|
33
|
+
return reject(assistant.errorify(`Session query error: ${e}`, {code: 500}));
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
})
|
|
@@ -39,7 +39,7 @@ Module.prototype.main = function () {
|
|
|
39
39
|
return resolve({data: newKeys});
|
|
40
40
|
})
|
|
41
41
|
.catch(e => {
|
|
42
|
-
return reject(assistant.errorify(`Failed to generate keys: ${e}`, {code: 500, sentry: true
|
|
42
|
+
return reject(assistant.errorify(`Failed to generate keys: ${e}`, {code: 500, sentry: true}));
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
})
|
|
@@ -37,10 +37,10 @@ Module.prototype.main = function () {
|
|
|
37
37
|
return resolve({data: {sessions: count, message: `Successfully signed ${uid} out of all sessions`}});
|
|
38
38
|
})
|
|
39
39
|
.catch(e => {
|
|
40
|
-
return reject(assistant.errorify(`Failed to sign out of all sessions: ${e}`, {code: 500
|
|
40
|
+
return reject(assistant.errorify(`Failed to sign out of all sessions: ${e}`, {code: 500}));
|
|
41
41
|
})
|
|
42
42
|
} catch (e) {
|
|
43
|
-
return reject(assistant.errorify(`Failed to sign out of all sessions: ${e}`, {code: 500
|
|
43
|
+
return reject(assistant.errorify(`Failed to sign out of all sessions: ${e}`, {code: 500}));
|
|
44
44
|
}
|
|
45
45
|
})
|
|
46
46
|
.catch(e => {
|
|
@@ -108,7 +108,7 @@ Module.prototype.signOutOfSession = function (uid, session) {
|
|
|
108
108
|
|
|
109
109
|
})
|
|
110
110
|
.catch(e => {
|
|
111
|
-
assistant.errorify(`Session query error for session ${session}: ${e}`, {code: 500, sentry: true
|
|
111
|
+
assistant.errorify(`Session query error for session ${session}: ${e}`, {code: 500, sentry: true});
|
|
112
112
|
|
|
113
113
|
return reject(e);
|
|
114
114
|
})
|