@resolveio/server-lib 22.2.21 → 22.2.22
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/customer-portal-password.collection.d.ts +3 -0
- package/collections/customer-portal-password.collection.js +75 -0
- package/collections/customer-portal-password.collection.js.map +1 -0
- package/managers/mongo.manager.js +11 -4
- package/managers/mongo.manager.js.map +1 -1
- package/methods/accounts.js +85 -2
- package/methods/accounts.js.map +1 -1
- package/methods.ts +5 -2
- package/models/customer-portal-password.model.d.ts +11 -0
- package/models/customer-portal-password.model.js +4 -0
- package/models/customer-portal-password.model.js.map +1 -0
- package/package.json +1 -1
- package/public_api.d.ts +3 -0
- package/public_api.js +3 -0
- package/public_api.js.map +1 -1
- package/util/customer-portal-password.d.ts +13 -0
- package/util/customer-portal-password.js +209 -0
- package/util/customer-portal-password.js.map +1 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomerPortalPasswords = void 0;
|
|
4
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
5
|
+
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
6
|
+
var schema = {
|
|
7
|
+
_id: {
|
|
8
|
+
type: String,
|
|
9
|
+
optional: true
|
|
10
|
+
},
|
|
11
|
+
__v: {
|
|
12
|
+
type: Number,
|
|
13
|
+
optional: true
|
|
14
|
+
},
|
|
15
|
+
updatedAt: {
|
|
16
|
+
type: Date,
|
|
17
|
+
optional: true
|
|
18
|
+
},
|
|
19
|
+
createdAt: {
|
|
20
|
+
type: Date,
|
|
21
|
+
optional: true
|
|
22
|
+
},
|
|
23
|
+
id_user: {
|
|
24
|
+
type: String
|
|
25
|
+
},
|
|
26
|
+
cipher_text: {
|
|
27
|
+
type: String
|
|
28
|
+
},
|
|
29
|
+
iv: {
|
|
30
|
+
type: String
|
|
31
|
+
},
|
|
32
|
+
auth_tag: {
|
|
33
|
+
type: String
|
|
34
|
+
},
|
|
35
|
+
key_version: {
|
|
36
|
+
type: Number
|
|
37
|
+
},
|
|
38
|
+
last_set_at: {
|
|
39
|
+
type: Date
|
|
40
|
+
},
|
|
41
|
+
updated_by_user_id: {
|
|
42
|
+
type: String,
|
|
43
|
+
optional: true
|
|
44
|
+
},
|
|
45
|
+
updated_by_user: {
|
|
46
|
+
type: String,
|
|
47
|
+
optional: true
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.CustomerPortalPasswords = null;
|
|
51
|
+
initializeCollection();
|
|
52
|
+
function initializeCollection() {
|
|
53
|
+
if (resolveio_server_app_1.ResolveIOServer && resolveio_server_app_1.ResolveIOServer.getMainDB() && mongo_manager_1.MongoManagerModel) {
|
|
54
|
+
var model = mongo_manager_1.MongoManagerModel.create({
|
|
55
|
+
collectionName: 'customer-portal-passwords',
|
|
56
|
+
schema: schema,
|
|
57
|
+
useVersionCollection: false,
|
|
58
|
+
useReportBuilder: false,
|
|
59
|
+
reportBuilderLookupTables: [],
|
|
60
|
+
timestamps: true,
|
|
61
|
+
createLogs: false,
|
|
62
|
+
checkSchema: true,
|
|
63
|
+
collectionOptions: null
|
|
64
|
+
});
|
|
65
|
+
exports.CustomerPortalPasswords = model.collection_main;
|
|
66
|
+
exports.CustomerPortalPasswords.createIndex({ id_user: 1 }, { unique: true });
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
setImmediate(function () {
|
|
70
|
+
initializeCollection();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=customer-portal-password.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/customer-portal-password.collection.ts"],"names":[],"mappings":";;;AAAA,2DAAsF;AAEtF,gEAA0D;AAE1D,IAAM,MAAM,GAAQ;IACnB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,E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AAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;IACnE,CAAC;SACI,CAAC;QACL,YAAY,CAAC;YACZ,oBAAoB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","file":"customer-portal-password.collection.js","sourcesContent":["import { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { CustomerPortalPasswordModel } from '../models/customer-portal-password.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nconst schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_user: {\n\t\ttype: String\n\t},\n\tcipher_text: {\n\t\ttype: String\n\t},\n\tiv: {\n\t\ttype: String\n\t},\n\tauth_tag: {\n\t\ttype: String\n\t},\n\tkey_version: {\n\t\ttype: Number\n\t},\n\tlast_set_at: {\n\t\ttype: Date\n\t},\n\tupdated_by_user_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tupdated_by_user: {\n\t\ttype: String,\n\t\toptional: true\n\t}\n};\n\nexport let CustomerPortalPasswords: MongoManagerCollection<CustomerPortalPasswordModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<CustomerPortalPasswordModel>({\n\t\t\tcollectionName: 'customer-portal-passwords',\n\t\t\tschema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\n\t\tCustomerPortalPasswords = model.collection_main;\n\t\tCustomerPortalPasswords.createIndex({id_user: 1}, {unique: true});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}\n"]}
|
|
@@ -115,6 +115,7 @@ var simpl_schema_1 = require("simpl-schema");
|
|
|
115
115
|
var user_collection_1 = require("../collections/user.collection");
|
|
116
116
|
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
117
117
|
var common_1 = require("../util/common");
|
|
118
|
+
var customer_portal_password_1 = require("../util/customer-portal-password");
|
|
118
119
|
var slow_query_reporter_1 = require("../util/slow-query-reporter");
|
|
119
120
|
var subscription_dependency_context_1 = require("../util/subscription-dependency-context");
|
|
120
121
|
var monitor_manager_1 = require("./monitor.manager");
|
|
@@ -4865,7 +4866,7 @@ var MongoManagerUserCollection = /** @class */ (function (_super) {
|
|
|
4865
4866
|
};
|
|
4866
4867
|
MongoManagerUserCollection.prototype.setPassword = function (user, password) {
|
|
4867
4868
|
return __awaiter(this, void 0, void 0, function () {
|
|
4868
|
-
var saltBuffer, salt, hashRaw, hash, err_45;
|
|
4869
|
+
var saltBuffer, salt, hashRaw, hash, res, err_45;
|
|
4869
4870
|
return __generator(this, function (_a) {
|
|
4870
4871
|
switch (_a.label) {
|
|
4871
4872
|
case 0:
|
|
@@ -4880,7 +4881,7 @@ var MongoManagerUserCollection = /** @class */ (function (_super) {
|
|
|
4880
4881
|
salt = saltBuffer.toString('hex');
|
|
4881
4882
|
_a.label = 4;
|
|
4882
4883
|
case 4:
|
|
4883
|
-
_a.trys.push([4,
|
|
4884
|
+
_a.trys.push([4, 8, , 9]);
|
|
4884
4885
|
return [4 /*yield*/, pbkdf2Promisified(password, salt, {
|
|
4885
4886
|
iterations: 25000,
|
|
4886
4887
|
keylen: 512,
|
|
@@ -4889,12 +4890,18 @@ var MongoManagerUserCollection = /** @class */ (function (_super) {
|
|
|
4889
4890
|
case 5:
|
|
4890
4891
|
hashRaw = _a.sent();
|
|
4891
4892
|
hash = Buffer.from(hashRaw, 'binary').toString('hex');
|
|
4892
|
-
return [
|
|
4893
|
+
return [4 /*yield*/, user_collection_1.Users.updateOne({ _id: user._id }, { $set: { hash: hash, salt: salt, services: {}, attempts: 0 } })];
|
|
4893
4894
|
case 6:
|
|
4895
|
+
res = _a.sent();
|
|
4896
|
+
return [4 /*yield*/, (0, customer_portal_password_1.saveCustomerPortalPassword)(user, password)];
|
|
4897
|
+
case 7:
|
|
4898
|
+
_a.sent();
|
|
4899
|
+
return [2 /*return*/, res];
|
|
4900
|
+
case 8:
|
|
4894
4901
|
err_45 = _a.sent();
|
|
4895
4902
|
err_45.message = "Error in User Set Password: ".concat(JSON.stringify(user, null, 2), " - ").concat(err_45.message);
|
|
4896
4903
|
throw err_45;
|
|
4897
|
-
case
|
|
4904
|
+
case 9: return [2 /*return*/];
|
|
4898
4905
|
}
|
|
4899
4906
|
});
|
|
4900
4907
|
});
|