@resolveio/server-lib 8.1.36 → 9.0.0
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/collections/app-status.collection.d.ts +2 -6
- package/collections/app-status.collection.js +4 -21
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.d.ts +2 -6
- package/collections/app-version.collection.js +4 -34
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.d.ts +2 -6
- package/collections/counter.collection.js +4 -34
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.d.ts +3 -7
- package/collections/cron-job-history.collection.js +5 -34
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.d.ts +2 -6
- package/collections/cron-job.collection.js +4 -33
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.d.ts +2 -6
- package/collections/email-history.collection.js +4 -21
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.d.ts +2 -6
- package/collections/email-verified.collection.js +5 -22
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.d.ts +2 -6
- package/collections/file.collection.js +4 -26
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.d.ts +2 -6
- package/collections/flag.collection.js +4 -21
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.d.ts +2 -6
- package/collections/log-method-latency.collection.js +7 -22
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.d.ts +2 -6
- package/collections/log-subscription.collection.js +9 -24
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.d.ts +2 -6
- package/collections/log.collection.js +9 -25
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.d.ts +2 -6
- package/collections/logged-in-users.collection.js +5 -32
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.d.ts +2 -5
- package/collections/method-call.collection.js +5 -11
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.d.ts +2 -5
- package/collections/method-response.collection.js +5 -11
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.d.ts +2 -6
- package/collections/monitor-cpu.collection.js +9 -26
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.d.ts +2 -6
- package/collections/monitor-https-inbound.collection.js +9 -26
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.d.ts +2 -6
- package/collections/monitor-https-outbound.collection.js +11 -28
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.d.ts +2 -6
- package/collections/monitor-memory.collection.js +8 -25
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.d.ts +2 -6
- package/collections/monitor-mongo.collection.js +8 -25
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.d.ts +2 -6
- package/collections/notification.collection.js +4 -21
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.d.ts +2 -6
- package/collections/queue-flag.collection.js +5 -22
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.d.ts +2 -6
- package/collections/queue-method.collection.js +6 -77
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.d.ts +2 -6
- package/collections/queue-response.collection.js +5 -34
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.d.ts +2 -6
- package/collections/report-builder-dashboard-builder.collection.js +6 -35
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.d.ts +2 -6
- package/collections/report-builder-library.collection.js +7 -36
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.d.ts +2 -6
- package/collections/report-builder-report.collection.js +7 -36
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.d.ts +3 -6
- package/collections/user-group.collection.js +5 -38
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.d.ts +2 -6
- package/collections/user-guide.collection.js +4 -26
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.d.ts +3 -6
- package/collections/user.collection.js +36 -62
- package/collections/user.collection.js.map +1 -1
- package/fixtures/cron-jobs.js +5 -5
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +2 -2
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +201 -185
- package/http/auth.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/managers/cron.manager.js +6 -6
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +10 -10
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +102 -0
- package/managers/mongo.manager.js +514 -0
- package/managers/mongo.manager.js.map +1 -0
- package/managers/monitor.manager.js +6 -6
- package/managers/monitor.manager.js.map +1 -1
- package/managers/queue-method.manager.js +14 -14
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +9 -7
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +23 -21
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +7 -7
- package/methods/aws.js.map +1 -1
- package/methods/collections.js +112 -119
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +5 -5
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +2 -2
- package/methods/cron-jobs.js.map +1 -1
- package/methods/logs.js +8 -8
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +6 -6
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +5 -5
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +2 -2
- package/methods/report-builder.js.map +1 -1
- package/models/report-builder.model.d.ts +1 -2
- package/models/report-builder.model.js.map +1 -1
- package/models/user.model.d.ts +9 -7
- package/models/user.model.js.map +1 -1
- package/package.json +26 -27
- package/public_api.js +1 -1
- package/publications/app-status.js +1 -1
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +1 -1
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +2 -2
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +3 -3
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -1
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +3 -3
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +1 -1
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +1 -1
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -1
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +2 -2
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +3 -3
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +4 -4
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -1
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -1
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -1
- package/publications/user-guides.js.map +1 -1
- package/server-app.d.ts +4 -1
- package/server-app.js +19 -28
- package/server-app.js.map +1 -1
- package/util/common.d.ts +2 -3
- package/util/common.js +16 -21
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +5 -5
- package/util/schema-report-builder.js.map +1 -1
- package/managers/database.manager.d.ts +0 -6
- package/managers/database.manager.js +0 -15
- package/managers/database.manager.js.map +0 -1
package/http/auth.js
CHANGED
|
@@ -46,7 +46,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
46
46
|
var _this = this;
|
|
47
47
|
// Login via HTTP, return refresh token if authenticated
|
|
48
48
|
app.post('/login', function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
49
|
-
var body, schema, user_1,
|
|
49
|
+
var body, schema, user_1, resAuth, emailData_1, emailData_2;
|
|
50
50
|
return __generator(this, function (_a) {
|
|
51
51
|
switch (_a.label) {
|
|
52
52
|
case 0:
|
|
@@ -55,7 +55,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
55
55
|
error: true,
|
|
56
56
|
result: 'Invalid header'
|
|
57
57
|
}));
|
|
58
|
-
return [3 /*break*/,
|
|
58
|
+
return [3 /*break*/, 8];
|
|
59
59
|
case 1:
|
|
60
60
|
body = request.body;
|
|
61
61
|
schema = new simpl_schema_1.default({
|
|
@@ -80,91 +80,97 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
80
80
|
return [2 /*return*/];
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
return [4 /*yield*/, user_collection_1.Users.findOne({ username: body.username })
|
|
83
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ username: body.username })];
|
|
84
84
|
case 2:
|
|
85
85
|
user_1 = _a.sent();
|
|
86
86
|
if (!!user_1) return [3 /*break*/, 4];
|
|
87
|
-
return [4 /*yield*/, user_collection_1.Users.findOne({ email: body.username })
|
|
87
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ email: body.username })];
|
|
88
88
|
case 3:
|
|
89
89
|
user_1 = _a.sent();
|
|
90
90
|
_a.label = 4;
|
|
91
91
|
case 4:
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (!user_1) {
|
|
93
|
+
response.send(JSON.stringify({
|
|
94
|
+
error: true,
|
|
95
|
+
result: 'Invalid Username And Password'
|
|
96
|
+
}));
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
return [4 /*yield*/, user_collection_1.Users.authenticate(user_1, body.password)];
|
|
94
100
|
case 5:
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
response.send(JSON.stringify({
|
|
141
|
-
error: true,
|
|
142
|
-
result: resAuth_1.error.message
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
101
|
+
resAuth = _a.sent();
|
|
102
|
+
if (!resAuth['error']) return [3 /*break*/, 6];
|
|
103
|
+
if (resAuth['error'] === 'Too Many Attempts') {
|
|
104
|
+
response.send(JSON.stringify({
|
|
105
|
+
error: true,
|
|
106
|
+
result: resAuth['error'] + '. A password reset link has been sent to your email, please reset your password.'
|
|
107
|
+
}));
|
|
108
|
+
user_1.services['forgot_password'] = jwt.sign({ id_user: user_1._id }, serverConfig['JWT_SECRET']);
|
|
109
|
+
emailData_1 = {
|
|
110
|
+
userToChangePassword: user_1.fullname,
|
|
111
|
+
userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
|
|
112
|
+
url: serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services['forgot_password']
|
|
113
|
+
};
|
|
114
|
+
user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).then(function (resUp) {
|
|
115
|
+
mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
|
|
116
|
+
var template = handlebars.compile(html);
|
|
117
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
118
|
+
return a === b;
|
|
119
|
+
});
|
|
120
|
+
mainServer.getMethodManager().sendEmail(user_1.email, 'ResolveIO (' + __1.ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData_1));
|
|
121
|
+
}, function (errEmail) { return console.log(errEmail); });
|
|
122
|
+
}, function (errUp) { });
|
|
123
|
+
}
|
|
124
|
+
else if (resAuth['error'] === 'No Salt Value Stored') {
|
|
125
|
+
response.send(JSON.stringify({
|
|
126
|
+
error: true,
|
|
127
|
+
result: 'A password reset link has been sent to your email, please reset your password.'
|
|
128
|
+
}));
|
|
129
|
+
user_1.services['forgot_password'] = jwt.sign({ id_user: user_1._id }, serverConfig['JWT_SECRET']);
|
|
130
|
+
emailData_2 = {
|
|
131
|
+
userToChangePassword: user_1.fullname,
|
|
132
|
+
userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
|
|
133
|
+
url: serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services['forgot_password']
|
|
134
|
+
};
|
|
135
|
+
user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).then(function (resUp) {
|
|
136
|
+
mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
|
|
137
|
+
var template = handlebars.compile(html);
|
|
138
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
139
|
+
return a === b;
|
|
140
|
+
});
|
|
141
|
+
mainServer.getMethodManager().sendEmail(user_1.email, 'ResolveIO (' + __1.ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData_2));
|
|
142
|
+
}, function (errEmail) { return console.log(errEmail); });
|
|
143
|
+
}, function (err) { });
|
|
145
144
|
}
|
|
146
145
|
else {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
result: {
|
|
152
|
-
token: jwt.sign({ id_user: resAuth_1.user._id }, serverConfig['JWT_SECRET'], {
|
|
153
|
-
expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
}));
|
|
157
|
-
});
|
|
158
|
-
}
|
|
146
|
+
response.send(JSON.stringify({
|
|
147
|
+
error: true,
|
|
148
|
+
result: resAuth['error']
|
|
149
|
+
}));
|
|
159
150
|
}
|
|
160
|
-
|
|
161
|
-
case 6:
|
|
151
|
+
return [3 /*break*/, 8];
|
|
152
|
+
case 6:
|
|
153
|
+
if (!(resAuth && resAuth['data'] && resAuth['data'].active)) return [3 /*break*/, 8];
|
|
154
|
+
return [4 /*yield*/, user_collection_1.Users.resetAttempts(resAuth['data'])];
|
|
155
|
+
case 7:
|
|
156
|
+
_a.sent();
|
|
157
|
+
response.send(JSON.stringify({
|
|
158
|
+
error: false,
|
|
159
|
+
result: {
|
|
160
|
+
token: jwt.sign({ id_user: resAuth['data']._id }, serverConfig['JWT_SECRET'], {
|
|
161
|
+
expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
_a.label = 8;
|
|
166
|
+
case 8: return [2 /*return*/];
|
|
162
167
|
}
|
|
163
168
|
});
|
|
164
169
|
}); });
|
|
165
170
|
app.post('/accessToken', function (request, response) {
|
|
166
171
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
172
|
var body, schema;
|
|
173
|
+
var _this = this;
|
|
168
174
|
return __generator(this, function (_a) {
|
|
169
175
|
if (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_SECONDARY_URL']) {
|
|
170
176
|
response.send(JSON.stringify({
|
|
@@ -205,10 +211,15 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
205
211
|
}));
|
|
206
212
|
}
|
|
207
213
|
else {
|
|
208
|
-
user_collection_1.Users.findById(decoded['id_user']).
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
214
|
+
user_collection_1.Users.findById(decoded['id_user']).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
switch (_a.label) {
|
|
217
|
+
case 0:
|
|
218
|
+
if (!user) return [3 /*break*/, 4];
|
|
219
|
+
if (!user.active) return [3 /*break*/, 2];
|
|
220
|
+
return [4 /*yield*/, user_collection_1.Users.resetAttempts(user)];
|
|
221
|
+
case 1:
|
|
222
|
+
_a.sent();
|
|
212
223
|
response.send(JSON.stringify({
|
|
213
224
|
error: false,
|
|
214
225
|
result: {
|
|
@@ -218,25 +229,27 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
218
229
|
user: user
|
|
219
230
|
}
|
|
220
231
|
}));
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
232
|
+
return [3 /*break*/, 3];
|
|
233
|
+
case 2:
|
|
234
|
+
response.send(JSON.stringify({
|
|
235
|
+
error: true,
|
|
236
|
+
result: 'Account is Disabled'
|
|
237
|
+
}));
|
|
238
|
+
_a.label = 3;
|
|
239
|
+
case 3: return [3 /*break*/, 5];
|
|
240
|
+
case 4:
|
|
241
|
+
response.send(JSON.stringify({
|
|
242
|
+
error: true,
|
|
243
|
+
result: 'Invalid User'
|
|
244
|
+
}));
|
|
245
|
+
_a.label = 5;
|
|
246
|
+
case 5: return [2 /*return*/];
|
|
228
247
|
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
response.send(JSON.stringify({
|
|
232
|
-
error: true,
|
|
233
|
-
result: 'Invalid User'
|
|
234
|
-
}));
|
|
235
|
-
}
|
|
236
|
-
}, function (error) {
|
|
248
|
+
});
|
|
249
|
+
}); }, function (error) {
|
|
237
250
|
response.send(JSON.stringify({
|
|
238
251
|
error: true,
|
|
239
|
-
result: 'Invalid
|
|
252
|
+
result: 'Invalid Mongo Get User'
|
|
240
253
|
}));
|
|
241
254
|
});
|
|
242
255
|
}
|
|
@@ -251,10 +264,15 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
251
264
|
}));
|
|
252
265
|
}
|
|
253
266
|
else {
|
|
254
|
-
user_collection_1.Users.findById(decoded['id_user']).
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
user_collection_1.Users.findById(decoded['id_user']).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
268
|
+
return __generator(this, function (_a) {
|
|
269
|
+
switch (_a.label) {
|
|
270
|
+
case 0:
|
|
271
|
+
if (!user) return [3 /*break*/, 4];
|
|
272
|
+
if (!user.active) return [3 /*break*/, 2];
|
|
273
|
+
return [4 /*yield*/, user_collection_1.Users.resetAttempts(user)];
|
|
274
|
+
case 1:
|
|
275
|
+
_a.sent();
|
|
258
276
|
response.send(JSON.stringify({
|
|
259
277
|
error: false,
|
|
260
278
|
result: {
|
|
@@ -264,25 +282,27 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
264
282
|
user: user
|
|
265
283
|
}
|
|
266
284
|
}));
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
285
|
+
return [3 /*break*/, 3];
|
|
286
|
+
case 2:
|
|
287
|
+
response.send(JSON.stringify({
|
|
288
|
+
error: true,
|
|
289
|
+
result: 'Account is Disabled'
|
|
290
|
+
}));
|
|
291
|
+
_a.label = 3;
|
|
292
|
+
case 3: return [3 /*break*/, 5];
|
|
293
|
+
case 4:
|
|
294
|
+
response.send(JSON.stringify({
|
|
295
|
+
error: true,
|
|
296
|
+
result: 'Invalid User'
|
|
297
|
+
}));
|
|
298
|
+
_a.label = 5;
|
|
299
|
+
case 5: return [2 /*return*/];
|
|
274
300
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
response.send(JSON.stringify({
|
|
278
|
-
error: true,
|
|
279
|
-
result: 'Invalid User'
|
|
280
|
-
}));
|
|
281
|
-
}
|
|
282
|
-
}, function (error) {
|
|
301
|
+
});
|
|
302
|
+
}); }, function (error) {
|
|
283
303
|
response.send(JSON.stringify({
|
|
284
304
|
error: true,
|
|
285
|
-
result: 'Invalid
|
|
305
|
+
result: 'Invalid Mongo Get User'
|
|
286
306
|
}));
|
|
287
307
|
});
|
|
288
308
|
}
|
|
@@ -334,7 +354,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
334
354
|
{ _id: decoded['id_user'] },
|
|
335
355
|
{ 'services.enrollment': body_1.enrollmentToken }
|
|
336
356
|
]
|
|
337
|
-
}
|
|
357
|
+
}, { projection: { _id: 1, __v: 1, username: 1, active: 1 } }).then(function (user) {
|
|
338
358
|
if (user) {
|
|
339
359
|
if (user.active) {
|
|
340
360
|
response.send(JSON.stringify({
|
|
@@ -360,7 +380,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
360
380
|
}, function (error) {
|
|
361
381
|
response.send(JSON.stringify({
|
|
362
382
|
error: true,
|
|
363
|
-
result: 'Invalid
|
|
383
|
+
result: 'Invalid Mongo Get User'
|
|
364
384
|
}));
|
|
365
385
|
});
|
|
366
386
|
}
|
|
@@ -400,6 +420,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
400
420
|
}
|
|
401
421
|
}
|
|
402
422
|
jwt.verify(body_2.enrollmentToken, serverConfig['JWT_SECRET'], function (err, decoded) { return __awaiter(_this, void 0, void 0, function () {
|
|
423
|
+
var _this = this;
|
|
403
424
|
return __generator(this, function (_a) {
|
|
404
425
|
if (err) {
|
|
405
426
|
response.send(JSON.stringify({
|
|
@@ -413,43 +434,40 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
413
434
|
{ _id: decoded['id_user'] },
|
|
414
435
|
{ 'services.enrollment': body_2.enrollmentToken }
|
|
415
436
|
]
|
|
416
|
-
}).
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
437
|
+
}).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
438
|
+
return __generator(this, function (_a) {
|
|
439
|
+
switch (_a.label) {
|
|
440
|
+
case 0:
|
|
441
|
+
if (!user) return [3 /*break*/, 4];
|
|
442
|
+
if (!user.active) return [3 /*break*/, 2];
|
|
443
|
+
return [4 /*yield*/, user_collection_1.Users.setPassword(user, body_2.password)];
|
|
444
|
+
case 1:
|
|
445
|
+
_a.sent();
|
|
446
|
+
response.send(JSON.stringify({
|
|
447
|
+
error: false,
|
|
448
|
+
result: true
|
|
449
|
+
}));
|
|
450
|
+
return [3 /*break*/, 3];
|
|
451
|
+
case 2:
|
|
452
|
+
response.send(JSON.stringify({
|
|
453
|
+
error: true,
|
|
454
|
+
result: 'Account is Disabled'
|
|
455
|
+
}));
|
|
456
|
+
_a.label = 3;
|
|
457
|
+
case 3: return [3 /*break*/, 5];
|
|
458
|
+
case 4:
|
|
459
|
+
response.send(JSON.stringify({
|
|
460
|
+
error: true,
|
|
461
|
+
result: 'Invalid User'
|
|
462
|
+
}));
|
|
463
|
+
_a.label = 5;
|
|
464
|
+
case 5: return [2 /*return*/];
|
|
441
465
|
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
response.send(JSON.stringify({
|
|
445
|
-
error: true,
|
|
446
|
-
result: 'Invalid User'
|
|
447
|
-
}));
|
|
448
|
-
}
|
|
449
|
-
}, function (error) {
|
|
466
|
+
});
|
|
467
|
+
}); }, function (error) {
|
|
450
468
|
response.send(JSON.stringify({
|
|
451
469
|
error: true,
|
|
452
|
-
result: 'Invalid
|
|
470
|
+
result: 'Invalid Mongo Get User'
|
|
453
471
|
}));
|
|
454
472
|
});
|
|
455
473
|
}
|
|
@@ -499,7 +517,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
499
517
|
{ _id: decoded['id_user'] },
|
|
500
518
|
{ 'services.forgot_password': body_3.forgotPasswordToken }
|
|
501
519
|
]
|
|
502
|
-
}
|
|
520
|
+
}, { projection: { _id: 1, __v: 1, username: 1, active: 1 } }).then(function (user) {
|
|
503
521
|
if (user) {
|
|
504
522
|
if (user.active) {
|
|
505
523
|
response.send(JSON.stringify({
|
|
@@ -519,13 +537,13 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
519
537
|
else {
|
|
520
538
|
response.send(JSON.stringify({
|
|
521
539
|
error: true,
|
|
522
|
-
result: 'Invalid
|
|
540
|
+
result: 'Invalid Token'
|
|
523
541
|
}));
|
|
524
542
|
}
|
|
525
543
|
}, function (error) {
|
|
526
544
|
response.send(JSON.stringify({
|
|
527
545
|
error: true,
|
|
528
|
-
result: 'Invalid
|
|
546
|
+
result: 'Invalid Mongo Get User'
|
|
529
547
|
}));
|
|
530
548
|
});
|
|
531
549
|
}
|
|
@@ -565,6 +583,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
565
583
|
}
|
|
566
584
|
}
|
|
567
585
|
jwt.verify(body_4.forgotPasswordToken, serverConfig['JWT_SECRET'], function (err, decoded) { return __awaiter(_this, void 0, void 0, function () {
|
|
586
|
+
var _this = this;
|
|
568
587
|
return __generator(this, function (_a) {
|
|
569
588
|
if (err) {
|
|
570
589
|
response.send(JSON.stringify({
|
|
@@ -578,43 +597,40 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
578
597
|
{ _id: decoded['id_user'] },
|
|
579
598
|
{ 'services.forgot_password': body_4.forgotPasswordToken }
|
|
580
599
|
]
|
|
581
|
-
}).
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
if (
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
600
|
+
}).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
601
|
+
return __generator(this, function (_a) {
|
|
602
|
+
switch (_a.label) {
|
|
603
|
+
case 0:
|
|
604
|
+
if (!user) return [3 /*break*/, 4];
|
|
605
|
+
if (!user.active) return [3 /*break*/, 2];
|
|
606
|
+
return [4 /*yield*/, user_collection_1.Users.setPassword(user, body_4.password)];
|
|
607
|
+
case 1:
|
|
608
|
+
_a.sent();
|
|
609
|
+
response.send(JSON.stringify({
|
|
610
|
+
error: false,
|
|
611
|
+
result: true
|
|
612
|
+
}));
|
|
613
|
+
return [3 /*break*/, 3];
|
|
614
|
+
case 2:
|
|
615
|
+
response.send(JSON.stringify({
|
|
616
|
+
error: true,
|
|
617
|
+
result: 'Account is Disabled'
|
|
618
|
+
}));
|
|
619
|
+
_a.label = 3;
|
|
620
|
+
case 3: return [3 /*break*/, 5];
|
|
621
|
+
case 4:
|
|
622
|
+
response.send(JSON.stringify({
|
|
623
|
+
error: true,
|
|
624
|
+
result: 'Invalid User'
|
|
625
|
+
}));
|
|
626
|
+
_a.label = 5;
|
|
627
|
+
case 5: return [2 /*return*/];
|
|
606
628
|
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
response.send(JSON.stringify({
|
|
610
|
-
error: true,
|
|
611
|
-
result: 'Invalid User'
|
|
612
|
-
}));
|
|
613
|
-
}
|
|
614
|
-
}, function (error) {
|
|
629
|
+
});
|
|
630
|
+
}); }, function (error) {
|
|
615
631
|
response.send(JSON.stringify({
|
|
616
632
|
error: true,
|
|
617
|
-
result: 'Invalid
|
|
633
|
+
result: 'Invalid Mongo Get User'
|
|
618
634
|
}));
|
|
619
635
|
});
|
|
620
636
|
}
|
|
@@ -655,11 +671,11 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
655
671
|
return [2 /*return*/];
|
|
656
672
|
}
|
|
657
673
|
}
|
|
658
|
-
return [4 /*yield*/, user_collection_1.Users.findOne({ username: body.username })
|
|
674
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ username: body.username })];
|
|
659
675
|
case 2:
|
|
660
676
|
user = _a.sent();
|
|
661
677
|
if (!!user) return [3 /*break*/, 4];
|
|
662
|
-
return [4 /*yield*/, user_collection_1.Users.findOne({ email: body.username })
|
|
678
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ email: body.username })];
|
|
663
679
|
case 3:
|
|
664
680
|
user = _a.sent();
|
|
665
681
|
_a.label = 4;
|