@resolveio/server-lib 12.5.54 → 12.5.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/client-server-app.d.ts +1 -0
- package/client-server-app.js +48 -0
- package/client-server-app.js.map +1 -0
- package/collections/app-status.collection.d.ts +3 -0
- package/collections/app-status.collection.js +51 -0
- package/collections/app-status.collection.js.map +1 -0
- package/collections/counter.collection.d.ts +3 -0
- package/collections/counter.collection.js +54 -0
- package/collections/counter.collection.js.map +1 -0
- package/collections/cron-job-history.collection.d.ts +3 -0
- package/collections/cron-job-history.collection.js +82 -0
- package/collections/cron-job-history.collection.js.map +1 -0
- package/collections/cron-job.collection.d.ts +3 -0
- package/collections/cron-job.collection.js +85 -0
- package/collections/cron-job.collection.js.map +1 -0
- package/collections/email-history.collection.d.ts +3 -0
- package/collections/email-history.collection.js +66 -0
- package/collections/email-history.collection.js.map +1 -0
- package/collections/email-verified.collection.d.ts +3 -0
- package/collections/email-verified.collection.js +61 -0
- package/collections/email-verified.collection.js.map +1 -0
- package/collections/file.collection.d.ts +3 -0
- package/collections/file.collection.js +73 -0
- package/collections/file.collection.js.map +1 -0
- package/collections/flag.collection.d.ts +3 -0
- package/collections/flag.collection.js +56 -0
- package/collections/flag.collection.js.map +1 -0
- package/collections/log-method-latency.collection.d.ts +3 -0
- package/collections/log-method-latency.collection.js +64 -0
- package/collections/log-method-latency.collection.js.map +1 -0
- package/collections/log-subscription.collection.d.ts +3 -0
- package/collections/log-subscription.collection.js +68 -0
- package/collections/log-subscription.collection.js.map +1 -0
- package/collections/log-ts.collection.d.ts +3 -0
- package/collections/log-ts.collection.js +78 -0
- package/collections/log-ts.collection.js.map +1 -0
- package/collections/log.collection.d.ts +3 -0
- package/collections/log.collection.js +77 -0
- package/collections/log.collection.js.map +1 -0
- package/collections/logged-in-users.collection.d.ts +3 -0
- package/collections/logged-in-users.collection.js +65 -0
- package/collections/logged-in-users.collection.js.map +1 -0
- package/collections/method-response.collection.d.ts +3 -0
- package/collections/method-response.collection.js +66 -0
- package/collections/method-response.collection.js.map +1 -0
- package/collections/monitor-cpu.collection.d.ts +3 -0
- package/collections/monitor-cpu.collection.js +63 -0
- package/collections/monitor-cpu.collection.js.map +1 -0
- package/collections/monitor-memory.collection.d.ts +3 -0
- package/collections/monitor-memory.collection.js +75 -0
- package/collections/monitor-memory.collection.js.map +1 -0
- package/collections/monitor-mongo.collection.d.ts +3 -0
- package/collections/monitor-mongo.collection.js +69 -0
- package/collections/monitor-mongo.collection.js.map +1 -0
- package/collections/notification.collection.d.ts +3 -0
- package/collections/notification.collection.js +51 -0
- package/collections/notification.collection.js.map +1 -0
- package/collections/report-builder-dashboard-builder.collection.d.ts +3 -0
- package/collections/report-builder-dashboard-builder.collection.js +109 -0
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -0
- package/collections/report-builder-library.collection.d.ts +3 -0
- package/collections/report-builder-library.collection.js +87 -0
- package/collections/report-builder-library.collection.js.map +1 -0
- package/collections/report-builder-report.collection.d.ts +4 -0
- package/collections/report-builder-report.collection.js +149 -0
- package/collections/report-builder-report.collection.js.map +1 -0
- package/collections/user-group.collection.d.ts +4 -0
- package/collections/user-group.collection.js +90 -0
- package/collections/user-group.collection.js.map +1 -0
- package/collections/user-guide.collection.d.ts +3 -0
- package/collections/user-guide.collection.js +57 -0
- package/collections/user-guide.collection.js.map +1 -0
- package/collections/user.collection.d.ts +4 -0
- package/collections/user.collection.js +259 -0
- package/collections/user.collection.js.map +1 -0
- package/cron/cron.d.ts +5 -0
- package/cron/cron.js +162 -0
- package/cron/cron.js.map +1 -0
- package/fixtures/cron-jobs.d.ts +1 -0
- package/fixtures/cron-jobs.js +73 -0
- package/fixtures/cron-jobs.js.map +1 -0
- package/fixtures/init.d.ts +1 -0
- package/fixtures/init.js +59 -0
- package/fixtures/init.js.map +1 -0
- package/http/auth.d.ts +2 -0
- package/http/auth.js +763 -0
- package/http/auth.js.map +1 -0
- package/http/health.d.ts +1 -0
- package/http/health.js +12 -0
- package/http/health.js.map +1 -0
- package/http/home.d.ts +2 -0
- package/http/home.js +66 -0
- package/http/home.js.map +1 -0
- package/index.d.ts +23 -0
- package/index.js +127 -0
- package/index.js.map +1 -0
- package/managers/cron.manager.d.ts +17 -0
- package/managers/cron.manager.js +242 -0
- package/managers/cron.manager.js.map +1 -0
- package/managers/method.manager.d.ts +38 -0
- package/managers/method.manager.js +595 -0
- package/managers/method.manager.js.map +1 -0
- package/managers/mongo.manager.d.ts +178 -0
- package/managers/mongo.manager.js +2221 -0
- package/managers/mongo.manager.js.map +1 -0
- package/managers/monitor.manager.d.ts +59 -0
- package/managers/monitor.manager.js +351 -0
- package/managers/monitor.manager.js.map +1 -0
- package/managers/subscription.manager.d.ts +50 -0
- package/managers/subscription.manager.js +1091 -0
- package/managers/subscription.manager.js.map +1 -0
- package/managers/subscription.performance.d.ts +1 -0
- package/{src/managers/subscription.performance.ts → managers/subscription.performance.js} +33 -68
- package/managers/subscription.performance.js.map +1 -0
- package/methods/accounts.d.ts +2 -0
- package/methods/accounts.js +274 -0
- package/methods/accounts.js.map +1 -0
- package/methods/aws.d.ts +2 -0
- package/methods/aws.js +617 -0
- package/methods/aws.js.map +1 -0
- package/methods/collections.d.ts +2 -0
- package/methods/collections.js +499 -0
- package/methods/collections.js.map +1 -0
- package/methods/counters.d.ts +2 -0
- package/methods/counters.js +122 -0
- package/methods/counters.js.map +1 -0
- package/methods/cron-jobs.d.ts +2 -0
- package/methods/cron-jobs.js +1315 -0
- package/methods/cron-jobs.js.map +1 -0
- package/methods/flags.d.ts +2 -0
- package/methods/flags.js +9 -0
- package/methods/flags.js.map +1 -0
- package/methods/logs.d.ts +2 -0
- package/methods/logs.js +371 -0
- package/methods/logs.js.map +1 -0
- package/methods/monitor.d.ts +2 -0
- package/methods/monitor.js +565 -0
- package/methods/monitor.js.map +1 -0
- package/methods/pdf.d.ts +2 -0
- package/methods/pdf.js +468 -0
- package/methods/pdf.js.map +1 -0
- package/methods/report-builder.d.ts +2 -0
- package/methods/report-builder.js +858 -0
- package/methods/report-builder.js.map +1 -0
- package/methods/support.d.ts +2 -0
- package/methods/support.js +246 -0
- package/methods/support.js.map +1 -0
- package/{src/models/app-status.model.ts → models/app-status.model.d.ts} +2 -3
- package/models/app-status.model.js +4 -0
- package/models/app-status.model.js.map +1 -0
- package/{src/models/billing-logged-in-users.model.ts → models/billing-logged-in-users.model.d.ts} +4 -5
- package/models/billing-logged-in-users.model.js +4 -0
- package/models/billing-logged-in-users.model.js.map +1 -0
- package/models/collection-document.model.d.ts +19 -0
- package/models/collection-document.model.js +4 -0
- package/models/collection-document.model.js.map +1 -0
- package/{src/models/counter.model.ts → models/counter.model.d.ts} +3 -4
- package/models/counter.model.js +4 -0
- package/models/counter.model.js.map +1 -0
- package/models/cron-job-history.model.d.ts +12 -0
- package/models/cron-job-history.model.js +4 -0
- package/models/cron-job-history.model.js.map +1 -0
- package/models/cron-job.model.d.ts +13 -0
- package/models/cron-job.model.js +4 -0
- package/models/cron-job.model.js.map +1 -0
- package/models/dialog.model.d.ts +23 -0
- package/models/dialog.model.js +4 -0
- package/models/dialog.model.js.map +1 -0
- package/{src/models/email-history.model.ts → models/email-history.model.d.ts} +7 -8
- package/models/email-history.model.js +4 -0
- package/models/email-history.model.js.map +1 -0
- package/{src/models/email-verified.model.ts → models/email-verified.model.d.ts} +5 -6
- package/models/email-verified.model.js +4 -0
- package/models/email-verified.model.js.map +1 -0
- package/{src/models/file.model.ts → models/file.model.d.ts} +7 -8
- package/models/file.model.js +4 -0
- package/models/file.model.js.map +1 -0
- package/{src/models/flag.model.ts → models/flag.model.d.ts} +3 -4
- package/models/flag.model.js +4 -0
- package/models/flag.model.js.map +1 -0
- package/{src/models/log-method-latency.model.ts → models/log-method-latency.model.d.ts} +4 -5
- package/models/log-method-latency.model.js +4 -0
- package/models/log-method-latency.model.js.map +1 -0
- package/{src/models/log-subscription.model.ts → models/log-subscription.model.d.ts} +6 -8
- package/models/log-subscription.model.js +4 -0
- package/models/log-subscription.model.js.map +1 -0
- package/{src/models/log.model.ts → models/log.model.d.ts} +10 -12
- package/models/log.model.js +4 -0
- package/models/log.model.js.map +1 -0
- package/{src/models/logged-in-users.model.ts → models/logged-in-users.model.d.ts} +5 -6
- package/models/logged-in-users.model.js +4 -0
- package/models/logged-in-users.model.js.map +1 -0
- package/{src/models/method-response.model.ts → models/method-response.model.d.ts} +6 -7
- package/models/method-response.model.js +4 -0
- package/models/method-response.model.js.map +1 -0
- package/models/method.model.d.ts +9 -0
- package/models/method.model.js +4 -0
- package/models/method.model.js.map +1 -0
- package/{src/models/monitor-cpu.model.ts → models/monitor-cpu.model.d.ts} +7 -9
- package/models/monitor-cpu.model.js +4 -0
- package/models/monitor-cpu.model.js.map +1 -0
- package/models/monitor-memory.model.d.ts +15 -0
- package/models/monitor-memory.model.js +4 -0
- package/models/monitor-memory.model.js.map +1 -0
- package/models/monitor-mongo.model.d.ts +13 -0
- package/models/monitor-mongo.model.js +4 -0
- package/models/monitor-mongo.model.js.map +1 -0
- package/{src/models/notification.model.ts → models/notification.model.d.ts} +2 -3
- package/models/notification.model.js +4 -0
- package/models/notification.model.js.map +1 -0
- package/models/pagination.model.d.ts +10 -0
- package/models/pagination.model.js +24 -0
- package/models/pagination.model.js.map +1 -0
- package/models/permission.model.d.ts +12 -0
- package/models/permission.model.js +4 -0
- package/models/permission.model.js.map +1 -0
- package/models/report-builder-dashboard-builder.model.d.ts +25 -0
- package/models/report-builder-dashboard-builder.model.js +4 -0
- package/models/report-builder-dashboard-builder.model.js.map +1 -0
- package/models/report-builder-library.model.d.ts +17 -0
- package/models/report-builder-library.model.js +4 -0
- package/models/report-builder-library.model.js.map +1 -0
- package/models/report-builder-report.model.d.ts +98 -0
- package/models/report-builder-report.model.js +4 -0
- package/models/report-builder-report.model.js.map +1 -0
- package/models/report-builder.model.d.ts +61 -0
- package/models/report-builder.model.js +4 -0
- package/models/report-builder.model.js.map +1 -0
- package/models/select-data-label.model.d.ts +9 -0
- package/models/select-data-label.model.js +4 -0
- package/models/select-data-label.model.js.map +1 -0
- package/models/server-response.model.d.ts +5 -0
- package/models/server-response.model.js +4 -0
- package/models/server-response.model.js.map +1 -0
- package/models/subscription.model.d.ts +23 -0
- package/models/subscription.model.js +4 -0
- package/models/subscription.model.js.map +1 -0
- package/models/support-ticket.model.d.ts +72 -0
- package/models/support-ticket.model.js +4 -0
- package/models/support-ticket.model.js.map +1 -0
- package/models/user-group.model.d.ts +19 -0
- package/models/user-group.model.js +4 -0
- package/models/user-group.model.js.map +1 -0
- package/{src/models/user-guide.model.ts → models/user-guide.model.d.ts} +4 -5
- package/models/user-guide.model.js +4 -0
- package/models/user-guide.model.js.map +1 -0
- package/models/user.model.d.ts +70 -0
- package/models/user.model.js +4 -0
- package/models/user.model.js.map +1 -0
- package/package.json +1 -1
- package/{src/public_api.ts → public_api.d.ts} +1 -1
- package/public_api.js +75 -0
- package/public_api.js.map +1 -0
- package/publications/app-status.d.ts +2 -0
- package/publications/app-status.js +17 -0
- package/publications/app-status.js.map +1 -0
- package/publications/cron-jobs.d.ts +2 -0
- package/publications/cron-jobs.js +33 -0
- package/publications/cron-jobs.js.map +1 -0
- package/publications/files.d.ts +2 -0
- package/publications/files.js +37 -0
- package/publications/files.js.map +1 -0
- package/publications/flags.d.ts +2 -0
- package/publications/flags.js +23 -0
- package/publications/flags.js.map +1 -0
- package/publications/logs.d.ts +2 -0
- package/publications/logs.js +165 -0
- package/publications/logs.js.map +1 -0
- package/publications/method-responses.d.ts +2 -0
- package/publications/method-responses.js +17 -0
- package/publications/method-responses.js.map +1 -0
- package/publications/notifications.d.ts +2 -0
- package/publications/notifications.js +17 -0
- package/publications/notifications.js.map +1 -0
- package/publications/report-builder-dashboard-builders.d.ts +2 -0
- package/publications/report-builder-dashboard-builders.js +43 -0
- package/publications/report-builder-dashboard-builders.js.map +1 -0
- package/publications/report-builder-libraries.d.ts +2 -0
- package/publications/report-builder-libraries.js +90 -0
- package/publications/report-builder-libraries.js.map +1 -0
- package/publications/report-builder-reports.d.ts +2 -0
- package/publications/report-builder-reports.js +51 -0
- package/publications/report-builder-reports.js.map +1 -0
- package/publications/super-admin.d.ts +2 -0
- package/publications/super-admin.js +17 -0
- package/publications/super-admin.js.map +1 -0
- package/publications/user-groups.d.ts +1 -0
- package/publications/user-groups.js +17 -0
- package/publications/user-groups.js.map +1 -0
- package/publications/user-guides.d.ts +1 -0
- package/publications/user-guides.js +17 -0
- package/publications/user-guides.js.map +1 -0
- package/server-app.d.ts +52 -0
- package/server-app.js +739 -0
- package/server-app.js.map +1 -0
- package/util/common.d.ts +24 -0
- package/util/common.js +511 -0
- package/util/common.js.map +1 -0
- package/util/schema-report-builder.d.ts +6 -0
- package/util/schema-report-builder.js +453 -0
- package/util/schema-report-builder.js.map +1 -0
- package/.nodemon.json +0 -5
- package/.vscode/settings.json +0 -3
- package/README.md +0 -22
- package/compileDTS.pl +0 -64
- package/gulpfile.js +0 -127
- package/mongodbensurers.js +0 -2
- package/mongostop.js +0 -3
- package/settings.development.json +0 -13
- package/src/client-server-app.ts +0 -7
- package/src/collections/app-status.collection.ts +0 -51
- package/src/collections/counter.collection.ts +0 -54
- package/src/collections/cron-job-history.collection.ts +0 -82
- package/src/collections/cron-job.collection.ts +0 -85
- package/src/collections/email-history.collection.ts +0 -66
- package/src/collections/email-verified.collection.ts +0 -61
- package/src/collections/file.collection.ts +0 -73
- package/src/collections/flag.collection.ts +0 -56
- package/src/collections/log-method-latency.collection.ts +0 -64
- package/src/collections/log-subscription.collection.ts +0 -68
- package/src/collections/log-ts.collection.ts +0 -78
- package/src/collections/log.collection.ts +0 -77
- package/src/collections/logged-in-users.collection.ts +0 -65
- package/src/collections/method-response.collection.ts +0 -66
- package/src/collections/monitor-cpu.collection.ts +0 -63
- package/src/collections/monitor-memory.collection.ts +0 -75
- package/src/collections/monitor-mongo.collection.ts +0 -69
- package/src/collections/notification.collection.ts +0 -51
- package/src/collections/report-builder-dashboard-builder.collection.ts +0 -109
- package/src/collections/report-builder-library.collection.ts +0 -89
- package/src/collections/report-builder-report.collection.ts +0 -149
- package/src/collections/user-group.collection.ts +0 -90
- package/src/collections/user-guide.collection.ts +0 -57
- package/src/collections/user.collection.ts +0 -259
- package/src/cron/cron.ts +0 -188
- package/src/fixtures/cron-jobs.ts +0 -25
- package/src/fixtures/init.ts +0 -10
- package/src/http/auth.ts +0 -732
- package/src/http/health.ts +0 -7
- package/src/http/home.ts +0 -71
- package/src/index.ts +0 -71
- package/src/managers/cron.manager.ts +0 -208
- package/src/managers/method.manager.ts +0 -607
- package/src/managers/mongo.manager.ts +0 -2282
- package/src/managers/monitor.manager.ts +0 -323
- package/src/managers/subscription.manager.ts +0 -1196
- package/src/methods/accounts.ts +0 -202
- package/src/methods/aws.ts +0 -507
- package/src/methods/collections.ts +0 -512
- package/src/methods/counters.ts +0 -75
- package/src/methods/cron-jobs.ts +0 -1454
- package/src/methods/flags.ts +0 -7
- package/src/methods/logs.ts +0 -327
- package/src/methods/monitor.ts +0 -548
- package/src/methods/pdf.ts +0 -615
- package/src/methods/report-builder.ts +0 -876
- package/src/methods/support.ts +0 -146
- package/src/models/collection-document.model.ts +0 -22
- package/src/models/cron-job-history.model.ts +0 -13
- package/src/models/cron-job.model.ts +0 -14
- package/src/models/dialog.model.ts +0 -25
- package/src/models/method.model.ts +0 -11
- package/src/models/monitor-memory.model.ts +0 -17
- package/src/models/monitor-mongo.model.ts +0 -15
- package/src/models/pagination.model.ts +0 -30
- package/src/models/permission.model.ts +0 -14
- package/src/models/report-builder-dashboard-builder.model.ts +0 -29
- package/src/models/report-builder-library.model.ts +0 -20
- package/src/models/report-builder-report.model.ts +0 -110
- package/src/models/report-builder.model.ts +0 -68
- package/src/models/select-data-label.model.ts +0 -9
- package/src/models/server-response.model.ts +0 -5
- package/src/models/subscription.model.ts +0 -64
- package/src/models/support-ticket.model.ts +0 -81
- package/src/models/user-group.model.ts +0 -23
- package/src/models/user.model.ts +0 -79
- package/src/publications/app-status.ts +0 -13
- package/src/publications/cron-jobs.ts +0 -30
- package/src/publications/files.ts +0 -34
- package/src/publications/flags.ts +0 -20
- package/src/publications/logs.ts +0 -164
- package/src/publications/method-responses.ts +0 -13
- package/src/publications/notifications.ts +0 -13
- package/src/publications/report-builder-dashboard-builders.ts +0 -39
- package/src/publications/report-builder-libraries.ts +0 -41
- package/src/publications/report-builder-reports.ts +0 -48
- package/src/publications/super-admin.ts +0 -13
- package/src/publications/user-groups.ts +0 -12
- package/src/publications/user-guides.ts +0 -12
- package/src/server-app.ts +0 -769
- package/src/util/common.ts +0 -519
- package/src/util/schema-report-builder.ts +0 -413
- package/tsconfig.json +0 -30
- package/tslint.json +0 -143
- /package/{src/private → private}/email-templates/enrollment.html +0 -0
- /package/{src/private → private}/email-templates/forgot-password.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-modified.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket.html +0 -0
- /package/{src/private → private}/images/ResolveIO.png +0 -0
package/http/auth.js
ADDED
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.setupAuthRoutes = void 0;
|
|
40
|
+
var user_collection_1 = require("../collections/user.collection");
|
|
41
|
+
var jwt = require("jsonwebtoken");
|
|
42
|
+
var handlebars = require("handlebars");
|
|
43
|
+
var __1 = require("..");
|
|
44
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
45
|
+
var simpl_schema_1 = require("simpl-schema");
|
|
46
|
+
var bodyParser = require("body-parser");
|
|
47
|
+
var jwt_decode_1 = require("jwt-decode");
|
|
48
|
+
function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
49
|
+
var _this = this;
|
|
50
|
+
app.post('/login365', bodyParser.json(), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
51
|
+
var body, schema, tokenData, token, decodedJWT, user, update;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
if (!(request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'])) return [3 /*break*/, 1];
|
|
56
|
+
response.send(JSON.stringify({
|
|
57
|
+
error: true,
|
|
58
|
+
result: 'Invalid header'
|
|
59
|
+
}));
|
|
60
|
+
return [3 /*break*/, 11];
|
|
61
|
+
case 1:
|
|
62
|
+
body = request.body;
|
|
63
|
+
schema = new simpl_schema_1.default({
|
|
64
|
+
id_token: {
|
|
65
|
+
type: String
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
schema.validate(body);
|
|
70
|
+
}
|
|
71
|
+
catch (errors) {
|
|
72
|
+
if (errors) {
|
|
73
|
+
console.error(new Date(), 'Error in HTTP Check (/login)', errors);
|
|
74
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/login365' + '\n\nData Being Checked\n' + JSON.stringify(body, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
75
|
+
response.send(JSON.stringify({
|
|
76
|
+
error: true,
|
|
77
|
+
result: 'Invalid Parameters'
|
|
78
|
+
}));
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
tokenData = body.id_token.split('&');
|
|
83
|
+
token = tokenData[0].split('=')[1];
|
|
84
|
+
decodedJWT = (0, jwt_decode_1.default)(token);
|
|
85
|
+
if (!(decodedJWT && decodedJWT['name'] && decodedJWT['preferred_username'] && decodedJWT['oid'])) return [3 /*break*/, 10];
|
|
86
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ 'other.ms_oid': decodedJWT['oid'] })];
|
|
87
|
+
case 2:
|
|
88
|
+
user = _a.sent();
|
|
89
|
+
if (!!user) return [3 /*break*/, 5];
|
|
90
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ email: decodedJWT['preferred_username'] })];
|
|
91
|
+
case 3:
|
|
92
|
+
user = _a.sent();
|
|
93
|
+
if (!user) return [3 /*break*/, 5];
|
|
94
|
+
return [4 /*yield*/, user_collection_1.Users.updateOne({ _id: user._id }, { $set: { 'other.ms_oid': decodedJWT['oid'] } })];
|
|
95
|
+
case 4:
|
|
96
|
+
_a.sent();
|
|
97
|
+
_a.label = 5;
|
|
98
|
+
case 5:
|
|
99
|
+
if (!!user) return [3 /*break*/, 7];
|
|
100
|
+
user = {
|
|
101
|
+
_id: (0, mongo_manager_1.objectIdHexString)(),
|
|
102
|
+
__v: 0,
|
|
103
|
+
roles: {
|
|
104
|
+
super_admin: false,
|
|
105
|
+
approvals: [],
|
|
106
|
+
groups: [],
|
|
107
|
+
notifications: [],
|
|
108
|
+
miscs: []
|
|
109
|
+
},
|
|
110
|
+
username: decodedJWT['preferred_username'],
|
|
111
|
+
email: decodedJWT['preferred_username'],
|
|
112
|
+
fullname: decodedJWT['name'],
|
|
113
|
+
active: true,
|
|
114
|
+
phonenumber: '',
|
|
115
|
+
readonly: false,
|
|
116
|
+
other: {
|
|
117
|
+
ms_oid: decodedJWT['oid']
|
|
118
|
+
},
|
|
119
|
+
attempts: 0,
|
|
120
|
+
salt: jwt.sign({ now: (Date.now() - 1000).toString() }, serverConfig['JWT_SECRET'], {
|
|
121
|
+
expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
|
|
122
|
+
}),
|
|
123
|
+
hash: jwt.sign({ now: (Date.now() + 1000).toString() }, serverConfig['JWT_SECRET'], {
|
|
124
|
+
expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
|
|
125
|
+
}),
|
|
126
|
+
last: new Date(),
|
|
127
|
+
settings: null,
|
|
128
|
+
services: null
|
|
129
|
+
};
|
|
130
|
+
return [4 /*yield*/, user_collection_1.Users.create(user)];
|
|
131
|
+
case 6:
|
|
132
|
+
_a.sent();
|
|
133
|
+
return [3 /*break*/, 9];
|
|
134
|
+
case 7:
|
|
135
|
+
update = false;
|
|
136
|
+
if (user.email !== decodedJWT['preferred_username']) {
|
|
137
|
+
user.email = decodedJWT['preferred_username'];
|
|
138
|
+
update = true;
|
|
139
|
+
}
|
|
140
|
+
if (user.fullname !== decodedJWT['name']) {
|
|
141
|
+
user.fullname = decodedJWT['name'];
|
|
142
|
+
update = true;
|
|
143
|
+
}
|
|
144
|
+
if (!update) return [3 /*break*/, 9];
|
|
145
|
+
return [4 /*yield*/, user_collection_1.Users.updateOne({ _id: user._id }, { $set: { email: user.email, fullname: user.fullname } })];
|
|
146
|
+
case 8:
|
|
147
|
+
_a.sent();
|
|
148
|
+
_a.label = 9;
|
|
149
|
+
case 9:
|
|
150
|
+
response.send(JSON.stringify({
|
|
151
|
+
error: false,
|
|
152
|
+
result: {
|
|
153
|
+
token: jwt.sign({ id_user: user._id }, serverConfig['JWT_SECRET'], {
|
|
154
|
+
expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
}));
|
|
158
|
+
return [3 /*break*/, 11];
|
|
159
|
+
case 10:
|
|
160
|
+
console.log('ERROR - 1', tokenData, token, decodedJWT);
|
|
161
|
+
response.send(JSON.stringify({
|
|
162
|
+
error: true,
|
|
163
|
+
result: 'Invalid Azure Token'
|
|
164
|
+
}));
|
|
165
|
+
_a.label = 11;
|
|
166
|
+
case 11: return [2 /*return*/];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}); });
|
|
170
|
+
// Login via HTTP, return refresh token if authenticated
|
|
171
|
+
app.post('/login', bodyParser.json(), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
172
|
+
var body, schema, user_1, resAuth, emailData_1, emailData_2;
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
switch (_a.label) {
|
|
175
|
+
case 0:
|
|
176
|
+
if (!(request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'])) return [3 /*break*/, 1];
|
|
177
|
+
response.send(JSON.stringify({
|
|
178
|
+
error: true,
|
|
179
|
+
result: 'Invalid header'
|
|
180
|
+
}));
|
|
181
|
+
return [3 /*break*/, 8];
|
|
182
|
+
case 1:
|
|
183
|
+
body = request.body;
|
|
184
|
+
schema = new simpl_schema_1.default({
|
|
185
|
+
username: {
|
|
186
|
+
type: String
|
|
187
|
+
},
|
|
188
|
+
password: {
|
|
189
|
+
type: String
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
try {
|
|
193
|
+
schema.validate(body);
|
|
194
|
+
}
|
|
195
|
+
catch (errors) {
|
|
196
|
+
if (errors) {
|
|
197
|
+
console.error(new Date(), 'Error in HTTP Check (/login)', errors);
|
|
198
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/login' + '\n\nData Being Checked\n' + JSON.stringify(body, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
199
|
+
response.send(JSON.stringify({
|
|
200
|
+
error: true,
|
|
201
|
+
result: 'Invalid Parameters'
|
|
202
|
+
}));
|
|
203
|
+
return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ username: body.username })];
|
|
207
|
+
case 2:
|
|
208
|
+
user_1 = _a.sent();
|
|
209
|
+
if (!!user_1) return [3 /*break*/, 4];
|
|
210
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ email: body.username })];
|
|
211
|
+
case 3:
|
|
212
|
+
user_1 = _a.sent();
|
|
213
|
+
_a.label = 4;
|
|
214
|
+
case 4:
|
|
215
|
+
if (!user_1) {
|
|
216
|
+
response.send(JSON.stringify({
|
|
217
|
+
error: true,
|
|
218
|
+
result: 'Invalid Username And Password'
|
|
219
|
+
}));
|
|
220
|
+
return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
return [4 /*yield*/, user_collection_1.Users.authenticate(user_1, body.password)];
|
|
223
|
+
case 5:
|
|
224
|
+
resAuth = _a.sent();
|
|
225
|
+
if (!resAuth['error']) return [3 /*break*/, 6];
|
|
226
|
+
if (resAuth['error'] === 'Too Many Attempts') {
|
|
227
|
+
response.send(JSON.stringify({
|
|
228
|
+
error: true,
|
|
229
|
+
result: resAuth['error'] + '. A password reset link has been sent to your email, please reset your password.'
|
|
230
|
+
}));
|
|
231
|
+
if (!user_1.services) {
|
|
232
|
+
user_1.services = {};
|
|
233
|
+
}
|
|
234
|
+
user_1.services['forgot_password'] = jwt.sign({ id_user: user_1._id }, serverConfig['JWT_SECRET']);
|
|
235
|
+
emailData_1 = {
|
|
236
|
+
userToChangePassword: user_1.fullname,
|
|
237
|
+
userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
|
|
238
|
+
url: (serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services['forgot_password'])
|
|
239
|
+
};
|
|
240
|
+
user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).then(function (resUp) {
|
|
241
|
+
mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
|
|
242
|
+
var template = handlebars.compile(html);
|
|
243
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
244
|
+
return a === b;
|
|
245
|
+
});
|
|
246
|
+
mainServer.getMethodManager().sendEmail(user_1.email, 'ResolveIO (' + __1.ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData_1), null, null, '');
|
|
247
|
+
}, function (errEmail) { return console.log(errEmail); });
|
|
248
|
+
}, function (errUp) { });
|
|
249
|
+
}
|
|
250
|
+
else if (resAuth['error'] === 'No Salt Value Stored') {
|
|
251
|
+
response.send(JSON.stringify({
|
|
252
|
+
error: true,
|
|
253
|
+
result: 'A password reset link has been sent to your email, please reset your password.'
|
|
254
|
+
}));
|
|
255
|
+
if (!user_1.services) {
|
|
256
|
+
user_1.services = {};
|
|
257
|
+
}
|
|
258
|
+
user_1.services['forgot_password'] = jwt.sign({ id_user: user_1._id }, serverConfig['JWT_SECRET']);
|
|
259
|
+
emailData_2 = {
|
|
260
|
+
userToChangePassword: user_1.fullname,
|
|
261
|
+
userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
|
|
262
|
+
url: (serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services['forgot_password'])
|
|
263
|
+
};
|
|
264
|
+
user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).then(function (resUp) {
|
|
265
|
+
mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
|
|
266
|
+
var template = handlebars.compile(html);
|
|
267
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
268
|
+
return a === b;
|
|
269
|
+
});
|
|
270
|
+
mainServer.getMethodManager().sendEmail(user_1.email, 'ResolveIO (' + __1.ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData_2), null, null, '');
|
|
271
|
+
}, function (errEmail) { return console.log(errEmail); });
|
|
272
|
+
}, function (err) { });
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
response.send(JSON.stringify({
|
|
276
|
+
error: true,
|
|
277
|
+
result: resAuth['error']
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
return [3 /*break*/, 8];
|
|
281
|
+
case 6:
|
|
282
|
+
if (!(resAuth && resAuth['data'] && resAuth['data'].active)) return [3 /*break*/, 8];
|
|
283
|
+
return [4 /*yield*/, user_collection_1.Users.resetAttempts(resAuth['data'])];
|
|
284
|
+
case 7:
|
|
285
|
+
_a.sent();
|
|
286
|
+
response.send(JSON.stringify({
|
|
287
|
+
error: false,
|
|
288
|
+
result: {
|
|
289
|
+
token: jwt.sign({ id_user: resAuth['data']._id }, serverConfig['JWT_SECRET'], {
|
|
290
|
+
expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
}));
|
|
294
|
+
_a.label = 8;
|
|
295
|
+
case 8: return [2 /*return*/];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}); });
|
|
299
|
+
app.post('/accessToken', bodyParser.json(), function (request, response) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
+
var body, schema;
|
|
302
|
+
var _this = this;
|
|
303
|
+
return __generator(this, function (_a) {
|
|
304
|
+
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']) {
|
|
305
|
+
response.send(JSON.stringify({
|
|
306
|
+
error: true,
|
|
307
|
+
result: 'Invalid header'
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
body = request.body;
|
|
312
|
+
schema = new simpl_schema_1.default({
|
|
313
|
+
refreshToken: {
|
|
314
|
+
type: String
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
try {
|
|
318
|
+
schema.validate(body);
|
|
319
|
+
}
|
|
320
|
+
catch (errors) {
|
|
321
|
+
if (errors) {
|
|
322
|
+
console.error(new Date(), 'Error in HTTP Check (/accessToken)', errors);
|
|
323
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/accessToken' + '\n\nData Being Checked\n' + JSON.stringify(body, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
324
|
+
response.send(JSON.stringify({
|
|
325
|
+
error: true,
|
|
326
|
+
result: 'Invalid Parameters'
|
|
327
|
+
}));
|
|
328
|
+
return [2 /*return*/];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
jwt.verify(body.refreshToken, serverConfig['JWT_SECRET'], function (err, decoded) {
|
|
332
|
+
if (err) {
|
|
333
|
+
response.send(JSON.stringify({
|
|
334
|
+
error: true,
|
|
335
|
+
result: 'Invalid Token'
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
user_collection_1.Users.findById(decoded['id_user']).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
340
|
+
return __generator(this, function (_a) {
|
|
341
|
+
if (user) {
|
|
342
|
+
if (user.active) {
|
|
343
|
+
response.send(JSON.stringify({
|
|
344
|
+
error: false,
|
|
345
|
+
result: {
|
|
346
|
+
token: jwt.sign({ id_user: user._id }, serverConfig['JWT_SECRET'], {
|
|
347
|
+
expiresIn: 3 * 24 * 60 * 60 * 1000 // 3 days
|
|
348
|
+
}),
|
|
349
|
+
user: user
|
|
350
|
+
}
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
response.send(JSON.stringify({
|
|
355
|
+
error: true,
|
|
356
|
+
result: 'Account is Disabled'
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
response.send(JSON.stringify({
|
|
362
|
+
error: true,
|
|
363
|
+
result: 'Invalid User'
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
return [2 /*return*/];
|
|
367
|
+
});
|
|
368
|
+
}); }, function (error) {
|
|
369
|
+
response.send(JSON.stringify({
|
|
370
|
+
error: true,
|
|
371
|
+
result: 'Invalid Mongo Get User'
|
|
372
|
+
}));
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
return [2 /*return*/];
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
app.post('/userWithEnrollmentToken', bodyParser.json(), function (request, response) {
|
|
382
|
+
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']) {
|
|
383
|
+
response.send(JSON.stringify({
|
|
384
|
+
error: true,
|
|
385
|
+
result: 'Invalid header'
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
var body_1 = request.body;
|
|
390
|
+
var schema = new simpl_schema_1.default({
|
|
391
|
+
enrollmentToken: {
|
|
392
|
+
type: String
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
try {
|
|
396
|
+
schema.validate(body_1);
|
|
397
|
+
}
|
|
398
|
+
catch (errors) {
|
|
399
|
+
if (errors) {
|
|
400
|
+
console.error(new Date(), 'Error in HTTP Check (/userWithEnrollmentToken)', errors);
|
|
401
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/userWithEnrollmentToken' + '\n\nData Being Checked\n' + JSON.stringify(body_1, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
402
|
+
response.send(JSON.stringify({
|
|
403
|
+
error: true,
|
|
404
|
+
result: 'Invalid Parameters'
|
|
405
|
+
}));
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
jwt.verify(body_1.enrollmentToken, serverConfig['JWT_SECRET'], function (err, decoded) {
|
|
410
|
+
if (err) {
|
|
411
|
+
response.send(JSON.stringify({
|
|
412
|
+
error: true,
|
|
413
|
+
result: 'Invalid Token'
|
|
414
|
+
}));
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
user_collection_1.Users.findOne({
|
|
418
|
+
$and: [
|
|
419
|
+
{ _id: decoded['id_user'] },
|
|
420
|
+
{ 'services.enrollment': body_1.enrollmentToken }
|
|
421
|
+
]
|
|
422
|
+
}, { projection: { _id: 1, __v: 1, username: 1, active: 1 } }).then(function (user) {
|
|
423
|
+
if (user) {
|
|
424
|
+
if (user.active) {
|
|
425
|
+
response.send(JSON.stringify({
|
|
426
|
+
error: false,
|
|
427
|
+
result: {
|
|
428
|
+
user: user
|
|
429
|
+
}
|
|
430
|
+
}));
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
response.send(JSON.stringify({
|
|
434
|
+
error: true,
|
|
435
|
+
result: 'Account is Disabled'
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
response.send(JSON.stringify({
|
|
441
|
+
error: true,
|
|
442
|
+
result: 'Invalid User'
|
|
443
|
+
}));
|
|
444
|
+
}
|
|
445
|
+
}, function (error) {
|
|
446
|
+
response.send(JSON.stringify({
|
|
447
|
+
error: true,
|
|
448
|
+
result: 'Invalid Mongo Get User'
|
|
449
|
+
}));
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
app.post('/setUserWithEnrollmentToken', bodyParser.json(), function (request, response) {
|
|
456
|
+
var _this = this;
|
|
457
|
+
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']) {
|
|
458
|
+
response.send(JSON.stringify({
|
|
459
|
+
error: true,
|
|
460
|
+
result: 'Invalid header'
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
var body_2 = request.body;
|
|
465
|
+
var schema = new simpl_schema_1.default({
|
|
466
|
+
enrollmentToken: {
|
|
467
|
+
type: String
|
|
468
|
+
},
|
|
469
|
+
password: {
|
|
470
|
+
type: String
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
try {
|
|
474
|
+
schema.validate(body_2);
|
|
475
|
+
}
|
|
476
|
+
catch (errors) {
|
|
477
|
+
if (errors) {
|
|
478
|
+
console.error(new Date(), 'Error in HTTP Check (/setUserWithEnrollmentToken)', errors);
|
|
479
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/setUserWithEnrollmentToken' + '\n\nData Being Checked\n' + JSON.stringify(body_2, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
480
|
+
response.send(JSON.stringify({
|
|
481
|
+
error: true,
|
|
482
|
+
result: 'Invalid Parameters'
|
|
483
|
+
}));
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
jwt.verify(body_2.enrollmentToken, serverConfig['JWT_SECRET'], function (err, decoded) { return __awaiter(_this, void 0, void 0, function () {
|
|
488
|
+
var _this = this;
|
|
489
|
+
return __generator(this, function (_a) {
|
|
490
|
+
if (err) {
|
|
491
|
+
response.send(JSON.stringify({
|
|
492
|
+
error: true,
|
|
493
|
+
result: 'Invalid Token'
|
|
494
|
+
}));
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
user_collection_1.Users.findOne({
|
|
498
|
+
$and: [
|
|
499
|
+
{ _id: decoded['id_user'] },
|
|
500
|
+
{ 'services.enrollment': body_2.enrollmentToken }
|
|
501
|
+
]
|
|
502
|
+
}).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
503
|
+
return __generator(this, function (_a) {
|
|
504
|
+
switch (_a.label) {
|
|
505
|
+
case 0:
|
|
506
|
+
if (!user) return [3 /*break*/, 4];
|
|
507
|
+
if (!user.active) return [3 /*break*/, 2];
|
|
508
|
+
return [4 /*yield*/, user_collection_1.Users.setPassword(user, body_2.password)];
|
|
509
|
+
case 1:
|
|
510
|
+
_a.sent();
|
|
511
|
+
response.send(JSON.stringify({
|
|
512
|
+
error: false,
|
|
513
|
+
result: true
|
|
514
|
+
}));
|
|
515
|
+
return [3 /*break*/, 3];
|
|
516
|
+
case 2:
|
|
517
|
+
response.send(JSON.stringify({
|
|
518
|
+
error: true,
|
|
519
|
+
result: 'Account is Disabled'
|
|
520
|
+
}));
|
|
521
|
+
_a.label = 3;
|
|
522
|
+
case 3: return [3 /*break*/, 5];
|
|
523
|
+
case 4:
|
|
524
|
+
response.send(JSON.stringify({
|
|
525
|
+
error: true,
|
|
526
|
+
result: 'Invalid User'
|
|
527
|
+
}));
|
|
528
|
+
_a.label = 5;
|
|
529
|
+
case 5: return [2 /*return*/];
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}); }, function (error) {
|
|
533
|
+
response.send(JSON.stringify({
|
|
534
|
+
error: true,
|
|
535
|
+
result: 'Invalid Mongo Get User'
|
|
536
|
+
}));
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
return [2 /*return*/];
|
|
540
|
+
});
|
|
541
|
+
}); });
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
app.post('/userWithForgotPasswordToken', bodyParser.json(), function (request, response) {
|
|
545
|
+
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']) {
|
|
546
|
+
response.send(JSON.stringify({
|
|
547
|
+
error: true,
|
|
548
|
+
result: 'Invalid header'
|
|
549
|
+
}));
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
var body_3 = request.body;
|
|
553
|
+
var schema = new simpl_schema_1.default({
|
|
554
|
+
forgotPasswordToken: {
|
|
555
|
+
type: String
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
try {
|
|
559
|
+
schema.validate(body_3);
|
|
560
|
+
}
|
|
561
|
+
catch (errors) {
|
|
562
|
+
if (errors) {
|
|
563
|
+
console.error(new Date(), 'Error in HTTP Check (/userWithForgotPasswordToken)', errors);
|
|
564
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/userWithForgotPasswordToken' + '\n\nData Being Checked\n' + JSON.stringify(body_3, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
565
|
+
response.send(JSON.stringify({
|
|
566
|
+
error: true,
|
|
567
|
+
result: 'Invalid Parameters'
|
|
568
|
+
}));
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
jwt.verify(body_3.forgotPasswordToken, serverConfig['JWT_SECRET'], function (err, decoded) {
|
|
573
|
+
if (err) {
|
|
574
|
+
response.send(JSON.stringify({
|
|
575
|
+
error: true,
|
|
576
|
+
result: 'Invalid Token'
|
|
577
|
+
}));
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
user_collection_1.Users.findOne({
|
|
581
|
+
$and: [
|
|
582
|
+
{ _id: decoded['id_user'] },
|
|
583
|
+
{ 'services.forgot_password': body_3.forgotPasswordToken }
|
|
584
|
+
]
|
|
585
|
+
}, { projection: { _id: 1, __v: 1, username: 1, active: 1 } }).then(function (user) {
|
|
586
|
+
if (user) {
|
|
587
|
+
if (user.active) {
|
|
588
|
+
response.send(JSON.stringify({
|
|
589
|
+
error: false,
|
|
590
|
+
result: {
|
|
591
|
+
user: user
|
|
592
|
+
}
|
|
593
|
+
}));
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
response.send(JSON.stringify({
|
|
597
|
+
error: true,
|
|
598
|
+
result: 'Account is Disabled'
|
|
599
|
+
}));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
response.send(JSON.stringify({
|
|
604
|
+
error: true,
|
|
605
|
+
result: 'Invalid Token'
|
|
606
|
+
}));
|
|
607
|
+
}
|
|
608
|
+
}, function (error) {
|
|
609
|
+
response.send(JSON.stringify({
|
|
610
|
+
error: true,
|
|
611
|
+
result: 'Invalid Mongo Get User'
|
|
612
|
+
}));
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
app.post('/setUserWithForgotPasswordToken', bodyParser.json(), function (request, response) {
|
|
619
|
+
var _this = this;
|
|
620
|
+
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']) {
|
|
621
|
+
response.send(JSON.stringify({
|
|
622
|
+
error: true,
|
|
623
|
+
result: 'Invalid header'
|
|
624
|
+
}));
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
var body_4 = request.body;
|
|
628
|
+
var schema = new simpl_schema_1.default({
|
|
629
|
+
forgotPasswordToken: {
|
|
630
|
+
type: String
|
|
631
|
+
},
|
|
632
|
+
password: {
|
|
633
|
+
type: String
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
try {
|
|
637
|
+
schema.validate(body_4);
|
|
638
|
+
}
|
|
639
|
+
catch (errors) {
|
|
640
|
+
if (errors) {
|
|
641
|
+
console.error(new Date(), 'Error in HTTP Check (/setUserWithForgotPasswordToken)', errors);
|
|
642
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/setUserWithForgotPasswordToken' + '\n\nData Being Checked\n' + JSON.stringify(body_4, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
643
|
+
response.send(JSON.stringify({
|
|
644
|
+
error: true,
|
|
645
|
+
result: 'Invalid Parameters'
|
|
646
|
+
}));
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
jwt.verify(body_4.forgotPasswordToken, serverConfig['JWT_SECRET'], function (err, decoded) { return __awaiter(_this, void 0, void 0, function () {
|
|
651
|
+
var _this = this;
|
|
652
|
+
return __generator(this, function (_a) {
|
|
653
|
+
if (err) {
|
|
654
|
+
response.send(JSON.stringify({
|
|
655
|
+
error: true,
|
|
656
|
+
result: 'Invalid Token'
|
|
657
|
+
}));
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
user_collection_1.Users.findOne({
|
|
661
|
+
$and: [
|
|
662
|
+
{ _id: decoded['id_user'] },
|
|
663
|
+
{ 'services.forgot_password': body_4.forgotPasswordToken }
|
|
664
|
+
]
|
|
665
|
+
}).then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
666
|
+
return __generator(this, function (_a) {
|
|
667
|
+
switch (_a.label) {
|
|
668
|
+
case 0:
|
|
669
|
+
if (!user) return [3 /*break*/, 4];
|
|
670
|
+
if (!user.active) return [3 /*break*/, 2];
|
|
671
|
+
return [4 /*yield*/, user_collection_1.Users.setPassword(user, body_4.password)];
|
|
672
|
+
case 1:
|
|
673
|
+
_a.sent();
|
|
674
|
+
response.send(JSON.stringify({
|
|
675
|
+
error: false,
|
|
676
|
+
result: true
|
|
677
|
+
}));
|
|
678
|
+
return [3 /*break*/, 3];
|
|
679
|
+
case 2:
|
|
680
|
+
response.send(JSON.stringify({
|
|
681
|
+
error: true,
|
|
682
|
+
result: 'Account is Disabled'
|
|
683
|
+
}));
|
|
684
|
+
_a.label = 3;
|
|
685
|
+
case 3: return [3 /*break*/, 5];
|
|
686
|
+
case 4:
|
|
687
|
+
response.send(JSON.stringify({
|
|
688
|
+
error: true,
|
|
689
|
+
result: 'Invalid User'
|
|
690
|
+
}));
|
|
691
|
+
_a.label = 5;
|
|
692
|
+
case 5: return [2 /*return*/];
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}); }, function (error) {
|
|
696
|
+
response.send(JSON.stringify({
|
|
697
|
+
error: true,
|
|
698
|
+
result: 'Invalid Mongo Get User'
|
|
699
|
+
}));
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
return [2 /*return*/];
|
|
703
|
+
});
|
|
704
|
+
}); });
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
app.post('/resetPassword', bodyParser.json(), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
708
|
+
var body, schema, user;
|
|
709
|
+
return __generator(this, function (_a) {
|
|
710
|
+
switch (_a.label) {
|
|
711
|
+
case 0:
|
|
712
|
+
if (!(request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'])) return [3 /*break*/, 1];
|
|
713
|
+
response.send(JSON.stringify({
|
|
714
|
+
error: true,
|
|
715
|
+
result: 'Invalid header'
|
|
716
|
+
}));
|
|
717
|
+
return [3 /*break*/, 5];
|
|
718
|
+
case 1:
|
|
719
|
+
body = request.body;
|
|
720
|
+
schema = new simpl_schema_1.default({
|
|
721
|
+
username: {
|
|
722
|
+
type: String
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
try {
|
|
726
|
+
schema.validate(body);
|
|
727
|
+
}
|
|
728
|
+
catch (errors) {
|
|
729
|
+
if (errors) {
|
|
730
|
+
console.error(new Date(), 'Error in HTTP Check (/resetPassword)', errors);
|
|
731
|
+
__1.ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', __1.ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/resetPassword' + '\n\nData Being Checked\n' + JSON.stringify(body, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
732
|
+
response.send(JSON.stringify({
|
|
733
|
+
error: true,
|
|
734
|
+
result: 'Invalid Parameters'
|
|
735
|
+
}));
|
|
736
|
+
return [2 /*return*/];
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ username: body.username })];
|
|
740
|
+
case 2:
|
|
741
|
+
user = _a.sent();
|
|
742
|
+
if (!!user) return [3 /*break*/, 4];
|
|
743
|
+
return [4 /*yield*/, user_collection_1.Users.findOne({ email: body.username })];
|
|
744
|
+
case 3:
|
|
745
|
+
user = _a.sent();
|
|
746
|
+
_a.label = 4;
|
|
747
|
+
case 4:
|
|
748
|
+
if (user) {
|
|
749
|
+
mainServer.getMethodManager().callMethodInternal.call(mainServer.getMethodManager(), 'resetUserPassword', user._id);
|
|
750
|
+
}
|
|
751
|
+
response.send(JSON.stringify({
|
|
752
|
+
error: false,
|
|
753
|
+
result: ''
|
|
754
|
+
}));
|
|
755
|
+
_a.label = 5;
|
|
756
|
+
case 5: return [2 /*return*/];
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}); });
|
|
760
|
+
}
|
|
761
|
+
exports.setupAuthRoutes = setupAuthRoutes;
|
|
762
|
+
|
|
763
|
+
//# sourceMappingURL=auth.js.map
|