@steedos/accounts 2.2.52-beta.5 → 2.2.52-beta.50
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/LICENSE.txt +2 -5
- package/lib/core/index.js +22 -22
- package/lib/core/index.js.map +1 -1
- package/lib/database-mongo/mongo.js +105 -102
- package/lib/database-mongo/mongo.js.map +1 -1
- package/lib/index.js +10 -20
- package/lib/index.js.map +1 -1
- package/lib/mail.js +5 -5
- package/lib/mail.js.map +1 -1
- package/lib/password/accounts-password.js +54 -41
- package/lib/password/accounts-password.js.map +1 -1
- package/lib/password/index.js +1 -1
- package/lib/password/index.js.map +1 -1
- package/lib/password/utils/encryption.js +3 -3
- package/lib/rest-express/endpoints/authorize.js +2 -2
- package/lib/rest-express/endpoints/get-user.js +2 -2
- package/lib/rest-express/endpoints/impersonate.js +2 -2
- package/lib/rest-express/endpoints/initServer.js +2 -2
- package/lib/rest-express/endpoints/login.js +2 -2
- package/lib/rest-express/endpoints/logout.js +2 -2
- package/lib/rest-express/endpoints/oauth/provider-callback.js +3 -3
- package/lib/rest-express/endpoints/oauth/provider-callback.js.map +1 -1
- package/lib/rest-express/endpoints/password/change-password.js +2 -2
- package/lib/rest-express/endpoints/password/register.js +2 -2
- package/lib/rest-express/endpoints/password/reset.js +4 -4
- package/lib/rest-express/endpoints/password/two-factor.js +6 -6
- package/lib/rest-express/endpoints/password/verify-email.js +6 -6
- package/lib/rest-express/endpoints/password/verify.js +4 -4
- package/lib/rest-express/endpoints/put-user-name.js +2 -2
- package/lib/rest-express/endpoints/refresh-access-token.js +2 -2
- package/lib/rest-express/endpoints/service-authenticate.js +2 -2
- package/lib/rest-express/endpoints/spaces.js +2 -2
- package/lib/rest-express/endpoints/steedos/create-tenant.js +2 -2
- package/lib/rest-express/endpoints/steedos/get-tenant.js +2 -2
- package/lib/rest-express/endpoints/steedos/settings.js +2 -2
- package/lib/rest-express/endpoints/update-session.js +2 -2
- package/lib/rest-express/express-middleware.js +1 -1
- package/lib/rest-express/express-middleware.js.map +1 -1
- package/lib/rest-express/user-loader.js +2 -2
- package/lib/rest-express/utils/steedos-auth.js +2 -2
- package/lib/rest-express/utils/steedos-auth.js.map +1 -1
- package/lib/rest-express/utils/users.js +4 -4
- package/lib/server/accounts-server.js +56 -30
- package/lib/server/accounts-server.js.map +1 -1
- package/lib/server/utils/email.js +2 -2
- package/lib/types/index.js +14 -14
- package/lib/types/index.js.map +1 -1
- package/package.json +14 -20
- package/src/core/index.ts +4 -4
- package/src/database-mongo/mongo.ts +29 -26
- package/src/index.ts +6 -16
- package/src/mail.ts +3 -3
- package/src/password/accounts-password.ts +17 -5
- package/src/server/accounts-server.ts +26 -3
- package/src/server/types/jwt-data.ts +10 -1
- package/src/types/types/connection-informations.ts +9 -0
- package/lib/oauth2/client.js +0 -1
- package/lib/oauth2/client.js.map +0 -1
- package/lib/oauth2/config.js +0 -14
- package/lib/oauth2/config.js.map +0 -1
- package/lib/oauth2/consent.js +0 -192
- package/lib/oauth2/consent.js.map +0 -1
- package/lib/oauth2/login.js +0 -166
- package/lib/oauth2/login.js.map +0 -1
- package/lib/oauth2/logout.js +0 -60
- package/lib/oauth2/logout.js.map +0 -1
- package/lib/oauth2/stub/oidc-cert.js +0 -67
- package/lib/oauth2/stub/oidc-cert.js.map +0 -1
- package/lib/saml-idp/config.js +0 -82
- package/lib/saml-idp/config.js.map +0 -1
- package/lib/saml-idp/connectedApps.js +0 -20
- package/lib/saml-idp/connectedApps.js.map +0 -1
- package/lib/saml-idp/express-middleware.js +0 -684
- package/lib/saml-idp/express-middleware.js.map +0 -1
- package/lib/saml-idp/index.js +0 -13
- package/lib/saml-idp/index.js.map +0 -1
- package/lib/saml-idp/simpleProfileMapper.js +0 -75
- package/lib/saml-idp/simpleProfileMapper.js.map +0 -1
- package/src/oauth2/client.ts +0 -0
- package/src/oauth2/config.ts +0 -15
- package/src/oauth2/consent.ts +0 -208
- package/src/oauth2/login.ts +0 -179
- package/src/oauth2/logout.ts +0 -66
- package/src/oauth2/stub/oidc-cert.ts +0 -86
- package/src/saml-idp/config.js +0 -85
- package/src/saml-idp/connectedApps.ts +0 -16
- package/src/saml-idp/express-middleware.js +0 -811
- package/src/saml-idp/index.ts +0 -14
- package/src/saml-idp/simpleProfileMapper.js +0 -82
- package/src/saml-idp/views/error.hbs +0 -11
- package/src/saml-idp/views/layout.hbs +0 -72
- package/src/saml-idp/views/samlresponse.hbs +0 -20
- package/src/saml-idp/views/settings.hbs +0 -175
- package/src/saml-idp/views/user.hbs +0 -261
- package/views/oauth2/consent.pug +0 -141
|
@@ -10,7 +10,7 @@ var objectql_1 = require("@steedos/objectql");
|
|
|
10
10
|
var moment = require("moment");
|
|
11
11
|
var toMongoID = function (objectId) {
|
|
12
12
|
if (typeof objectId === "string") {
|
|
13
|
-
return new mongodb_1.
|
|
13
|
+
return new mongodb_1.ObjectId(objectId);
|
|
14
14
|
}
|
|
15
15
|
return objectId;
|
|
16
16
|
};
|
|
@@ -31,7 +31,7 @@ var defaultOptions = {
|
|
|
31
31
|
};
|
|
32
32
|
var Mongo = /** @class */ (function () {
|
|
33
33
|
function Mongo(db, options) {
|
|
34
|
-
this.options = (0, lodash_1.merge)(
|
|
34
|
+
this.options = (0, lodash_1.merge)(tslib_1.__assign({}, defaultOptions), options);
|
|
35
35
|
if (!db) {
|
|
36
36
|
throw new Error("A database connection is required");
|
|
37
37
|
}
|
|
@@ -43,9 +43,9 @@ var Mongo = /** @class */ (function () {
|
|
|
43
43
|
this.spaceUserCollection = this.db.collection(this.options.spaceUserCollectionName);
|
|
44
44
|
}
|
|
45
45
|
Mongo.prototype.findValidSessionsByUserId = function (userId, is_phone) {
|
|
46
|
-
return
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
47
47
|
var query, sessions;
|
|
48
|
-
return
|
|
48
|
+
return tslib_1.__generator(this, function (_a) {
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0:
|
|
51
51
|
query = {
|
|
@@ -75,8 +75,8 @@ var Mongo = /** @class */ (function () {
|
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
77
|
Mongo.prototype.setupIndexes = function () {
|
|
78
|
-
return
|
|
79
|
-
return
|
|
78
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
79
|
+
return tslib_1.__generator(this, function (_a) {
|
|
80
80
|
switch (_a.label) {
|
|
81
81
|
case 0: return [4 /*yield*/, this.sessionCollection.createIndex("token", {
|
|
82
82
|
unique: true,
|
|
@@ -102,14 +102,14 @@ var Mongo = /** @class */ (function () {
|
|
|
102
102
|
});
|
|
103
103
|
};
|
|
104
104
|
Mongo.prototype.createUser = function (_a) {
|
|
105
|
-
var password = _a.password, username = _a.username, email = _a.email, email_verified = _a.email_verified, mobile = _a.mobile, mobile_verified = _a.mobile_verified, cleanUser =
|
|
106
|
-
return
|
|
105
|
+
var password = _a.password, username = _a.username, email = _a.email, email_verified = _a.email_verified, mobile = _a.mobile, mobile_verified = _a.mobile_verified, cleanUser = tslib_1.__rest(_a, ["password", "username", "email", "email_verified", "mobile", "mobile_verified"]);
|
|
106
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
107
107
|
var user, encryptedMobile, encryptedName, ret;
|
|
108
108
|
var _b;
|
|
109
|
-
return
|
|
109
|
+
return tslib_1.__generator(this, function (_c) {
|
|
110
110
|
switch (_c.label) {
|
|
111
111
|
case 0:
|
|
112
|
-
user =
|
|
112
|
+
user = tslib_1.__assign(tslib_1.__assign({}, cleanUser), (_b = { services: {} }, _b[this.options.timestamps.createdAt] = this.options.dateProvider(), _b[this.options.timestamps.updatedAt] = this.options.dateProvider(), _b));
|
|
113
113
|
if (password) {
|
|
114
114
|
user.services.password = { bcrypt: password };
|
|
115
115
|
}
|
|
@@ -150,15 +150,15 @@ var Mongo = /** @class */ (function () {
|
|
|
150
150
|
return [4 /*yield*/, this.collection.insertOne(user)];
|
|
151
151
|
case 5:
|
|
152
152
|
ret = _c.sent();
|
|
153
|
-
return [2 /*return*/,
|
|
153
|
+
return [2 /*return*/, user._id];
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
};
|
|
158
158
|
Mongo.prototype.findUserById = function (userId) {
|
|
159
|
-
return
|
|
159
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
160
160
|
var id, user;
|
|
161
|
-
return
|
|
161
|
+
return tslib_1.__generator(this, function (_a) {
|
|
162
162
|
switch (_a.label) {
|
|
163
163
|
case 0:
|
|
164
164
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -176,9 +176,9 @@ var Mongo = /** @class */ (function () {
|
|
|
176
176
|
});
|
|
177
177
|
};
|
|
178
178
|
Mongo.prototype.findUserByEmail = function (email) {
|
|
179
|
-
return
|
|
179
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
180
180
|
var user;
|
|
181
|
-
return
|
|
181
|
+
return tslib_1.__generator(this, function (_a) {
|
|
182
182
|
switch (_a.label) {
|
|
183
183
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
184
184
|
email: email.toLowerCase(),
|
|
@@ -194,9 +194,9 @@ var Mongo = /** @class */ (function () {
|
|
|
194
194
|
});
|
|
195
195
|
};
|
|
196
196
|
Mongo.prototype.findUserByMobile = function (mobile) {
|
|
197
|
-
return
|
|
197
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
198
198
|
var selector, encryptedMobile, user;
|
|
199
|
-
return
|
|
199
|
+
return tslib_1.__generator(this, function (_a) {
|
|
200
200
|
switch (_a.label) {
|
|
201
201
|
case 0:
|
|
202
202
|
selector = {
|
|
@@ -220,9 +220,9 @@ var Mongo = /** @class */ (function () {
|
|
|
220
220
|
});
|
|
221
221
|
};
|
|
222
222
|
Mongo.prototype.findUserByUsername = function (username) {
|
|
223
|
-
return
|
|
223
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
224
224
|
var filter, user;
|
|
225
|
-
return
|
|
225
|
+
return tslib_1.__generator(this, function (_a) {
|
|
226
226
|
switch (_a.label) {
|
|
227
227
|
case 0:
|
|
228
228
|
filter = this.options.caseSensitiveUserName
|
|
@@ -242,9 +242,9 @@ var Mongo = /** @class */ (function () {
|
|
|
242
242
|
});
|
|
243
243
|
};
|
|
244
244
|
Mongo.prototype.findPasswordHash = function (userId) {
|
|
245
|
-
return
|
|
245
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
246
246
|
var user;
|
|
247
|
-
return
|
|
247
|
+
return tslib_1.__generator(this, function (_a) {
|
|
248
248
|
switch (_a.label) {
|
|
249
249
|
case 0: return [4 /*yield*/, this.findUserById(userId)];
|
|
250
250
|
case 1:
|
|
@@ -258,9 +258,9 @@ var Mongo = /** @class */ (function () {
|
|
|
258
258
|
});
|
|
259
259
|
};
|
|
260
260
|
Mongo.prototype.findUserByEmailVerificationToken = function (token) {
|
|
261
|
-
return
|
|
261
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
262
262
|
var user;
|
|
263
|
-
return
|
|
263
|
+
return tslib_1.__generator(this, function (_a) {
|
|
264
264
|
switch (_a.label) {
|
|
265
265
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
266
266
|
"services.email.verificationTokens.token": token,
|
|
@@ -276,9 +276,9 @@ var Mongo = /** @class */ (function () {
|
|
|
276
276
|
});
|
|
277
277
|
};
|
|
278
278
|
Mongo.prototype.findUserByResetPasswordToken = function (token) {
|
|
279
|
-
return
|
|
279
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
280
280
|
var user;
|
|
281
|
-
return
|
|
281
|
+
return tslib_1.__generator(this, function (_a) {
|
|
282
282
|
switch (_a.label) {
|
|
283
283
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
284
284
|
"services.password.reset.token": token,
|
|
@@ -294,10 +294,10 @@ var Mongo = /** @class */ (function () {
|
|
|
294
294
|
});
|
|
295
295
|
};
|
|
296
296
|
Mongo.prototype.findUserByServiceId = function (serviceName, serviceId) {
|
|
297
|
-
return
|
|
297
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
298
298
|
var user;
|
|
299
299
|
var _a;
|
|
300
|
-
return
|
|
300
|
+
return tslib_1.__generator(this, function (_b) {
|
|
301
301
|
switch (_b.label) {
|
|
302
302
|
case 0: return [4 /*yield*/, this.collection.findOne((_a = {},
|
|
303
303
|
_a["services.".concat(serviceName, ".id")] = serviceId,
|
|
@@ -325,10 +325,10 @@ var Mongo = /** @class */ (function () {
|
|
|
325
325
|
// return user;
|
|
326
326
|
// }
|
|
327
327
|
Mongo.prototype.addEmail = function (userId, newEmail, verified) {
|
|
328
|
-
return
|
|
328
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
329
329
|
var id, ret;
|
|
330
330
|
var _a;
|
|
331
|
-
return
|
|
331
|
+
return tslib_1.__generator(this, function (_b) {
|
|
332
332
|
switch (_b.label) {
|
|
333
333
|
case 0:
|
|
334
334
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -347,7 +347,7 @@ var Mongo = /** @class */ (function () {
|
|
|
347
347
|
})];
|
|
348
348
|
case 1:
|
|
349
349
|
ret = _b.sent();
|
|
350
|
-
if (ret.
|
|
350
|
+
if (ret.matchedCount === 0) {
|
|
351
351
|
throw new Error("User not found");
|
|
352
352
|
}
|
|
353
353
|
return [2 /*return*/];
|
|
@@ -356,10 +356,10 @@ var Mongo = /** @class */ (function () {
|
|
|
356
356
|
});
|
|
357
357
|
};
|
|
358
358
|
Mongo.prototype.removeEmail = function (userId, email) {
|
|
359
|
-
return
|
|
359
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
360
360
|
var id, ret;
|
|
361
361
|
var _a;
|
|
362
|
-
return
|
|
362
|
+
return tslib_1.__generator(this, function (_b) {
|
|
363
363
|
switch (_b.label) {
|
|
364
364
|
case 0:
|
|
365
365
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -373,7 +373,7 @@ var Mongo = /** @class */ (function () {
|
|
|
373
373
|
})];
|
|
374
374
|
case 1:
|
|
375
375
|
ret = _b.sent();
|
|
376
|
-
if (ret.
|
|
376
|
+
if (ret.matchedCount === 0) {
|
|
377
377
|
throw new Error("User not found");
|
|
378
378
|
}
|
|
379
379
|
return [2 /*return*/];
|
|
@@ -382,10 +382,10 @@ var Mongo = /** @class */ (function () {
|
|
|
382
382
|
});
|
|
383
383
|
};
|
|
384
384
|
Mongo.prototype.verifyEmail = function (userId, email) {
|
|
385
|
-
return
|
|
385
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
386
386
|
var id, ret;
|
|
387
387
|
var _a;
|
|
388
|
-
return
|
|
388
|
+
return tslib_1.__generator(this, function (_b) {
|
|
389
389
|
switch (_b.label) {
|
|
390
390
|
case 0:
|
|
391
391
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -412,7 +412,7 @@ var Mongo = /** @class */ (function () {
|
|
|
412
412
|
})];
|
|
413
413
|
case 2:
|
|
414
414
|
_b.sent();
|
|
415
|
-
if (ret.
|
|
415
|
+
if (ret.matchedCount === 0) {
|
|
416
416
|
throw new Error("User not found");
|
|
417
417
|
}
|
|
418
418
|
return [2 /*return*/];
|
|
@@ -422,9 +422,9 @@ var Mongo = /** @class */ (function () {
|
|
|
422
422
|
};
|
|
423
423
|
// 如果开启了加密功能,则获取加密后的字段值
|
|
424
424
|
Mongo.prototype.getEncryptedSpaceUserFieldValue = function (value, fieldName) {
|
|
425
|
-
return
|
|
425
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
426
426
|
var objectql, objFields, datasource, encryptedValue;
|
|
427
|
-
return
|
|
427
|
+
return tslib_1.__generator(this, function (_a) {
|
|
428
428
|
switch (_a.label) {
|
|
429
429
|
case 0:
|
|
430
430
|
objectql = require('@steedos/objectql');
|
|
@@ -446,10 +446,10 @@ var Mongo = /** @class */ (function () {
|
|
|
446
446
|
});
|
|
447
447
|
};
|
|
448
448
|
Mongo.prototype.verifyMobile = function (userId, mobile) {
|
|
449
|
-
return
|
|
449
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
450
450
|
var id, encryptedMobile, ret;
|
|
451
451
|
var _a;
|
|
452
|
-
return
|
|
452
|
+
return tslib_1.__generator(this, function (_b) {
|
|
453
453
|
switch (_b.label) {
|
|
454
454
|
case 0:
|
|
455
455
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -479,7 +479,7 @@ var Mongo = /** @class */ (function () {
|
|
|
479
479
|
})];
|
|
480
480
|
case 3:
|
|
481
481
|
_b.sent();
|
|
482
|
-
if (ret.
|
|
482
|
+
if (ret.matchedCount === 0) {
|
|
483
483
|
throw new Error("User not found");
|
|
484
484
|
}
|
|
485
485
|
return [2 /*return*/];
|
|
@@ -488,10 +488,10 @@ var Mongo = /** @class */ (function () {
|
|
|
488
488
|
});
|
|
489
489
|
};
|
|
490
490
|
Mongo.prototype.setMobile = function (userId, newMobile) {
|
|
491
|
-
return
|
|
491
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
492
492
|
var id, encryptedMobile, existed, user, ret;
|
|
493
493
|
var _a;
|
|
494
|
-
return
|
|
494
|
+
return tslib_1.__generator(this, function (_b) {
|
|
495
495
|
switch (_b.label) {
|
|
496
496
|
case 0:
|
|
497
497
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -508,7 +508,7 @@ var Mongo = /** @class */ (function () {
|
|
|
508
508
|
if (existed > 0) {
|
|
509
509
|
throw new Error("该手机号已被其他用户注册");
|
|
510
510
|
}
|
|
511
|
-
return [4 /*yield*/, this.collection.findOne({ _id: id }, {
|
|
511
|
+
return [4 /*yield*/, this.collection.findOne({ _id: id }, { projection: { mobile: 1 } })];
|
|
512
512
|
case 3:
|
|
513
513
|
user = _b.sent();
|
|
514
514
|
if (!(user && user.mobile != newMobile)) return [3 /*break*/, 6];
|
|
@@ -544,10 +544,10 @@ var Mongo = /** @class */ (function () {
|
|
|
544
544
|
});
|
|
545
545
|
};
|
|
546
546
|
Mongo.prototype.setEmail = function (userId, newEmail) {
|
|
547
|
-
return
|
|
547
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
548
548
|
var id, existed, user, ret;
|
|
549
549
|
var _a;
|
|
550
|
-
return
|
|
550
|
+
return tslib_1.__generator(this, function (_b) {
|
|
551
551
|
switch (_b.label) {
|
|
552
552
|
case 0:
|
|
553
553
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -561,7 +561,7 @@ var Mongo = /** @class */ (function () {
|
|
|
561
561
|
if (existed > 0) {
|
|
562
562
|
throw new Error("该邮箱已被其他用户注册");
|
|
563
563
|
}
|
|
564
|
-
return [4 /*yield*/, this.collection.findOne({ _id: id }, {
|
|
564
|
+
return [4 /*yield*/, this.collection.findOne({ _id: id }, { projection: { email: 1 } })];
|
|
565
565
|
case 2:
|
|
566
566
|
user = _b.sent();
|
|
567
567
|
if (!(user && user.email != newEmail)) return [3 /*break*/, 5];
|
|
@@ -597,10 +597,10 @@ var Mongo = /** @class */ (function () {
|
|
|
597
597
|
});
|
|
598
598
|
};
|
|
599
599
|
Mongo.prototype.setUsername = function (userId, newUsername) {
|
|
600
|
-
return
|
|
600
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
601
601
|
var id, ret;
|
|
602
602
|
var _a;
|
|
603
|
-
return
|
|
603
|
+
return tslib_1.__generator(this, function (_b) {
|
|
604
604
|
switch (_b.label) {
|
|
605
605
|
case 0:
|
|
606
606
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -615,7 +615,7 @@ var Mongo = /** @class */ (function () {
|
|
|
615
615
|
})];
|
|
616
616
|
case 1:
|
|
617
617
|
ret = _b.sent();
|
|
618
|
-
if (ret.
|
|
618
|
+
if (ret.matchedCount === 0) {
|
|
619
619
|
throw new Error("User not found");
|
|
620
620
|
}
|
|
621
621
|
return [2 /*return*/];
|
|
@@ -624,10 +624,10 @@ var Mongo = /** @class */ (function () {
|
|
|
624
624
|
});
|
|
625
625
|
};
|
|
626
626
|
Mongo.prototype.setPassword = function (userId, newPassword) {
|
|
627
|
-
return
|
|
627
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
628
628
|
var id, ret;
|
|
629
629
|
var _a;
|
|
630
|
-
return
|
|
630
|
+
return tslib_1.__generator(this, function (_b) {
|
|
631
631
|
switch (_b.label) {
|
|
632
632
|
case 0:
|
|
633
633
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -648,7 +648,7 @@ var Mongo = /** @class */ (function () {
|
|
|
648
648
|
})];
|
|
649
649
|
case 1:
|
|
650
650
|
ret = _b.sent();
|
|
651
|
-
if (ret.
|
|
651
|
+
if (ret.matchedCount === 0) {
|
|
652
652
|
throw new Error("User not found");
|
|
653
653
|
}
|
|
654
654
|
return [2 /*return*/];
|
|
@@ -657,10 +657,10 @@ var Mongo = /** @class */ (function () {
|
|
|
657
657
|
});
|
|
658
658
|
};
|
|
659
659
|
Mongo.prototype.setService = function (userId, serviceName, service) {
|
|
660
|
-
return
|
|
660
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
661
661
|
var id;
|
|
662
662
|
var _a;
|
|
663
|
-
return
|
|
663
|
+
return tslib_1.__generator(this, function (_b) {
|
|
664
664
|
switch (_b.label) {
|
|
665
665
|
case 0:
|
|
666
666
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -680,10 +680,10 @@ var Mongo = /** @class */ (function () {
|
|
|
680
680
|
});
|
|
681
681
|
};
|
|
682
682
|
Mongo.prototype.unsetService = function (userId, serviceName) {
|
|
683
|
-
return
|
|
683
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
684
684
|
var id;
|
|
685
685
|
var _a, _b;
|
|
686
|
-
return
|
|
686
|
+
return tslib_1.__generator(this, function (_c) {
|
|
687
687
|
switch (_c.label) {
|
|
688
688
|
case 0:
|
|
689
689
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -705,10 +705,10 @@ var Mongo = /** @class */ (function () {
|
|
|
705
705
|
});
|
|
706
706
|
};
|
|
707
707
|
Mongo.prototype.setUserDeactivated = function (userId, deactivated) {
|
|
708
|
-
return
|
|
708
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
709
709
|
var id;
|
|
710
710
|
var _a;
|
|
711
|
-
return
|
|
711
|
+
return tslib_1.__generator(this, function (_b) {
|
|
712
712
|
switch (_b.label) {
|
|
713
713
|
case 0:
|
|
714
714
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -737,6 +737,7 @@ var Mongo = /** @class */ (function () {
|
|
|
737
737
|
var is_phone = connection.is_phone;
|
|
738
738
|
var is_tablet = connection.is_tablet;
|
|
739
739
|
var space = connection.space;
|
|
740
|
+
var provider = connection.provider;
|
|
740
741
|
if (userAgent) {
|
|
741
742
|
var foo = userAgent.split(" Space/");
|
|
742
743
|
if (foo.length > 1) {
|
|
@@ -755,6 +756,7 @@ var Mongo = /** @class */ (function () {
|
|
|
755
756
|
is_phone: is_phone,
|
|
756
757
|
is_tablet: is_tablet,
|
|
757
758
|
login_expiration_in_days: login_expiration_in_days,
|
|
759
|
+
user_provider: provider
|
|
758
760
|
};
|
|
759
761
|
}
|
|
760
762
|
return {
|
|
@@ -763,18 +765,19 @@ var Mongo = /** @class */ (function () {
|
|
|
763
765
|
is_phone: is_phone,
|
|
764
766
|
is_tablet: is_tablet,
|
|
765
767
|
login_expiration_in_days: login_expiration_in_days,
|
|
768
|
+
user_provider: provider
|
|
766
769
|
};
|
|
767
770
|
};
|
|
768
771
|
Mongo.prototype.createSession = function (userId, token, connection, extraData) {
|
|
769
772
|
if (connection === void 0) { connection = {}; }
|
|
770
|
-
return
|
|
773
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
771
774
|
var infos, session, ret;
|
|
772
775
|
var _a;
|
|
773
|
-
return
|
|
776
|
+
return tslib_1.__generator(this, function (_b) {
|
|
774
777
|
switch (_b.label) {
|
|
775
778
|
case 0:
|
|
776
779
|
infos = this.resolveInfo(connection);
|
|
777
|
-
session =
|
|
780
|
+
session = tslib_1.__assign(tslib_1.__assign({ userId: userId, token: token }, infos), (_a = { extraData: extraData, valid: true }, _a[this.options.timestamps.createdAt] = this.options.dateProvider(), _a[this.options.timestamps.updatedAt] = this.options.dateProvider(), _a));
|
|
778
781
|
if (this.options.idProvider) {
|
|
779
782
|
session._id = this.options.idProvider();
|
|
780
783
|
}
|
|
@@ -784,16 +787,16 @@ var Mongo = /** @class */ (function () {
|
|
|
784
787
|
return [4 /*yield*/, this.updateMeteorSession(userId, token, infos)];
|
|
785
788
|
case 2:
|
|
786
789
|
_b.sent();
|
|
787
|
-
return [2 /*return*/, ret.
|
|
790
|
+
return [2 /*return*/, ret.insertedId.toString()];
|
|
788
791
|
}
|
|
789
792
|
});
|
|
790
793
|
});
|
|
791
794
|
};
|
|
792
795
|
Mongo.prototype.updateSession = function (sessionId, connection) {
|
|
793
|
-
return
|
|
796
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
794
797
|
var _id, infos, _set;
|
|
795
798
|
var _a;
|
|
796
|
-
return
|
|
799
|
+
return tslib_1.__generator(this, function (_b) {
|
|
797
800
|
switch (_b.label) {
|
|
798
801
|
case 0:
|
|
799
802
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
@@ -820,10 +823,10 @@ var Mongo = /** @class */ (function () {
|
|
|
820
823
|
});
|
|
821
824
|
};
|
|
822
825
|
Mongo.prototype.invalidateSession = function (sessionId) {
|
|
823
|
-
return
|
|
826
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
824
827
|
var _id, session;
|
|
825
828
|
var _a;
|
|
826
|
-
return
|
|
829
|
+
return tslib_1.__generator(this, function (_b) {
|
|
827
830
|
switch (_b.label) {
|
|
828
831
|
case 0:
|
|
829
832
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
@@ -852,9 +855,9 @@ var Mongo = /** @class */ (function () {
|
|
|
852
855
|
});
|
|
853
856
|
};
|
|
854
857
|
Mongo.prototype.invalidateAllSessions = function (userId) {
|
|
855
|
-
return
|
|
858
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
856
859
|
var _a;
|
|
857
|
-
return
|
|
860
|
+
return tslib_1.__generator(this, function (_b) {
|
|
858
861
|
switch (_b.label) {
|
|
859
862
|
case 0: return [4 /*yield*/, this.sessionCollection.updateMany({ userId: userId }, {
|
|
860
863
|
$set: (_a = {
|
|
@@ -871,9 +874,9 @@ var Mongo = /** @class */ (function () {
|
|
|
871
874
|
});
|
|
872
875
|
};
|
|
873
876
|
Mongo.prototype.findSessionByToken = function (token) {
|
|
874
|
-
return
|
|
877
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
875
878
|
var session;
|
|
876
|
-
return
|
|
879
|
+
return tslib_1.__generator(this, function (_a) {
|
|
877
880
|
switch (_a.label) {
|
|
878
881
|
case 0: return [4 /*yield*/, this.sessionCollection.findOne({ token: token })];
|
|
879
882
|
case 1:
|
|
@@ -887,9 +890,9 @@ var Mongo = /** @class */ (function () {
|
|
|
887
890
|
});
|
|
888
891
|
};
|
|
889
892
|
Mongo.prototype.findSessionById = function (sessionId) {
|
|
890
|
-
return
|
|
893
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
891
894
|
var _id, session;
|
|
892
|
-
return
|
|
895
|
+
return tslib_1.__generator(this, function (_a) {
|
|
893
896
|
switch (_a.label) {
|
|
894
897
|
case 0:
|
|
895
898
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
@@ -907,9 +910,9 @@ var Mongo = /** @class */ (function () {
|
|
|
907
910
|
});
|
|
908
911
|
};
|
|
909
912
|
Mongo.prototype.addEmailVerificationToken = function (userId, email, token) {
|
|
910
|
-
return
|
|
913
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
911
914
|
var _id;
|
|
912
|
-
return
|
|
915
|
+
return tslib_1.__generator(this, function (_a) {
|
|
913
916
|
switch (_a.label) {
|
|
914
917
|
case 0:
|
|
915
918
|
_id = this.options.convertUserIdToMongoObjectId
|
|
@@ -932,9 +935,9 @@ var Mongo = /** @class */ (function () {
|
|
|
932
935
|
});
|
|
933
936
|
};
|
|
934
937
|
Mongo.prototype.addResetPasswordToken = function (userId, email, token, reason) {
|
|
935
|
-
return
|
|
938
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
936
939
|
var _id;
|
|
937
|
-
return
|
|
940
|
+
return tslib_1.__generator(this, function (_a) {
|
|
938
941
|
switch (_a.label) {
|
|
939
942
|
case 0:
|
|
940
943
|
_id = this.options.convertUserIdToMongoObjectId
|
|
@@ -958,8 +961,8 @@ var Mongo = /** @class */ (function () {
|
|
|
958
961
|
});
|
|
959
962
|
};
|
|
960
963
|
Mongo.prototype.setResetPassword = function (userId, email, newPassword) {
|
|
961
|
-
return
|
|
962
|
-
return
|
|
964
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
965
|
+
return tslib_1.__generator(this, function (_a) {
|
|
963
966
|
switch (_a.label) {
|
|
964
967
|
case 0: return [4 /*yield*/, this.setPassword(userId, newPassword)];
|
|
965
968
|
case 1:
|
|
@@ -970,10 +973,10 @@ var Mongo = /** @class */ (function () {
|
|
|
970
973
|
});
|
|
971
974
|
};
|
|
972
975
|
Mongo.prototype.applyCode = function (name, owner, nextCode, MAX_FAILURE_COUNT, EFFECTIVE_TIME) {
|
|
973
|
-
return
|
|
976
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
974
977
|
var now, query, record, doc, result;
|
|
975
978
|
var _a;
|
|
976
|
-
return
|
|
979
|
+
return tslib_1.__generator(this, function (_b) {
|
|
977
980
|
switch (_b.label) {
|
|
978
981
|
case 0:
|
|
979
982
|
now = new Date();
|
|
@@ -1005,7 +1008,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1005
1008
|
return [4 /*yield*/, this.codeCollection.insertOne(doc)];
|
|
1006
1009
|
case 3:
|
|
1007
1010
|
result = _b.sent();
|
|
1008
|
-
record = result
|
|
1011
|
+
record = result;
|
|
1009
1012
|
_b.label = 4;
|
|
1010
1013
|
case 4: return [2 /*return*/, record];
|
|
1011
1014
|
}
|
|
@@ -1013,9 +1016,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1013
1016
|
});
|
|
1014
1017
|
};
|
|
1015
1018
|
Mongo.prototype.addVerificationCode = function (user, code, options) {
|
|
1016
|
-
return
|
|
1019
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1017
1020
|
var foundedUser, owner, ret;
|
|
1018
|
-
return
|
|
1021
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1019
1022
|
switch (_a.label) {
|
|
1020
1023
|
case 0:
|
|
1021
1024
|
foundedUser = null;
|
|
@@ -1041,9 +1044,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1041
1044
|
});
|
|
1042
1045
|
};
|
|
1043
1046
|
Mongo.prototype.verifyCodeByName = function (name, code) {
|
|
1044
|
-
return
|
|
1047
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1045
1048
|
var now, query, result;
|
|
1046
|
-
return
|
|
1049
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1047
1050
|
switch (_a.label) {
|
|
1048
1051
|
case 0:
|
|
1049
1052
|
now = new Date();
|
|
@@ -1067,9 +1070,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1067
1070
|
});
|
|
1068
1071
|
};
|
|
1069
1072
|
Mongo.prototype.verifyCodeByOwner = function (owner, code) {
|
|
1070
|
-
return
|
|
1073
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1071
1074
|
var now, query, result;
|
|
1072
|
-
return
|
|
1075
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1073
1076
|
switch (_a.label) {
|
|
1074
1077
|
case 0:
|
|
1075
1078
|
now = new Date();
|
|
@@ -1095,9 +1098,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1095
1098
|
});
|
|
1096
1099
|
};
|
|
1097
1100
|
Mongo.prototype.checkVerificationCode = function (user, code) {
|
|
1098
|
-
return
|
|
1101
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1099
1102
|
var name, record;
|
|
1100
|
-
return
|
|
1103
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1101
1104
|
switch (_a.label) {
|
|
1102
1105
|
case 0:
|
|
1103
1106
|
name = null;
|
|
@@ -1118,9 +1121,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1118
1121
|
});
|
|
1119
1122
|
};
|
|
1120
1123
|
Mongo.prototype.findUserByVerificationCode = function (user, code) {
|
|
1121
|
-
return
|
|
1124
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1122
1125
|
var foundedUser, owner, record;
|
|
1123
|
-
return
|
|
1126
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1124
1127
|
switch (_a.label) {
|
|
1125
1128
|
case 0:
|
|
1126
1129
|
foundedUser = null;
|
|
@@ -1167,9 +1170,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1167
1170
|
});
|
|
1168
1171
|
};
|
|
1169
1172
|
Mongo.prototype.getMySpaces = function (userId) {
|
|
1170
|
-
return
|
|
1173
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1171
1174
|
var userSpaces, spaceIds, spaces;
|
|
1172
|
-
return
|
|
1175
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1173
1176
|
switch (_a.label) {
|
|
1174
1177
|
case 0: return [4 /*yield*/, this.db
|
|
1175
1178
|
.collection("space_users")
|
|
@@ -1192,9 +1195,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1192
1195
|
});
|
|
1193
1196
|
};
|
|
1194
1197
|
Mongo.prototype.updateMeteorSession = function (userId, token, infos) {
|
|
1195
|
-
return
|
|
1198
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1196
1199
|
var when, login_expiration_in_days, is_phone, is_tablet, stampedAuthToken, hashedToken, _user, data;
|
|
1197
|
-
return
|
|
1200
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1198
1201
|
switch (_a.label) {
|
|
1199
1202
|
case 0:
|
|
1200
1203
|
when = new Date();
|
|
@@ -1237,9 +1240,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1237
1240
|
});
|
|
1238
1241
|
};
|
|
1239
1242
|
Mongo.prototype.destroyMeteorToken = function (userId, token) {
|
|
1240
|
-
return
|
|
1243
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1241
1244
|
var stampedAuthToken, hashedTokenDoc, loginToken;
|
|
1242
|
-
return
|
|
1245
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1243
1246
|
switch (_a.label) {
|
|
1244
1247
|
case 0:
|
|
1245
1248
|
stampedAuthToken = {
|
|
@@ -1263,8 +1266,8 @@ var Mongo = /** @class */ (function () {
|
|
|
1263
1266
|
});
|
|
1264
1267
|
};
|
|
1265
1268
|
Mongo.prototype.getInviteInfo = function (id) {
|
|
1266
|
-
return
|
|
1267
|
-
return
|
|
1269
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1270
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1268
1271
|
switch (_a.label) {
|
|
1269
1272
|
case 0: return [4 /*yield*/, this.inviteCollection.findOne({ _id: id })];
|
|
1270
1273
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1273,8 +1276,8 @@ var Mongo = /** @class */ (function () {
|
|
|
1273
1276
|
});
|
|
1274
1277
|
};
|
|
1275
1278
|
Mongo.prototype.updateUser = function (userId, options) {
|
|
1276
|
-
return
|
|
1277
|
-
return
|
|
1279
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1280
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1278
1281
|
return [2 /*return*/, this.collection.updateOne({ _id: userId }, options)];
|
|
1279
1282
|
});
|
|
1280
1283
|
});
|