@steedos/accounts 2.2.55-beta.9 → 2.3.0-beta.4
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/lib/core/index.js +26 -28
- package/lib/core/index.js.map +1 -1
- package/lib/database-mongo/mongo.js +141 -154
- package/lib/database-mongo/mongo.js.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/mail.js +6 -6
- package/lib/mail.js.map +1 -1
- package/lib/password/accounts-password.js +112 -233
- package/lib/password/accounts-password.js.map +1 -1
- package/lib/password/utils/encryption.js +4 -4
- package/lib/password/utils/encryption.js.map +1 -1
- package/lib/rest-express/endpoints/authorize.js +1 -1
- package/lib/rest-express/endpoints/get-user.js +1 -1
- package/lib/rest-express/endpoints/impersonate.js +4 -4
- package/lib/rest-express/endpoints/impersonate.js.map +1 -1
- package/lib/rest-express/endpoints/initServer.js +4 -4
- package/lib/rest-express/endpoints/initServer.js.map +1 -1
- package/lib/rest-express/endpoints/login.js +5 -5
- package/lib/rest-express/endpoints/login.js.map +1 -1
- package/lib/rest-express/endpoints/logout.js +4 -4
- package/lib/rest-express/endpoints/logout.js.map +1 -1
- package/lib/rest-express/endpoints/oauth/provider-callback.js +4 -4
- package/lib/rest-express/endpoints/oauth/provider-callback.js.map +1 -1
- package/lib/rest-express/endpoints/password/change-password.js +5 -5
- package/lib/rest-express/endpoints/password/change-password.js.map +1 -1
- package/lib/rest-express/endpoints/password/register.js +13 -39
- package/lib/rest-express/endpoints/password/register.js.map +1 -1
- package/lib/rest-express/endpoints/password/reset.js +8 -8
- package/lib/rest-express/endpoints/password/reset.js.map +1 -1
- package/lib/rest-express/endpoints/password/two-factor.js +14 -14
- package/lib/rest-express/endpoints/password/two-factor.js.map +1 -1
- package/lib/rest-express/endpoints/password/verify-email.js +12 -12
- package/lib/rest-express/endpoints/password/verify-email.js.map +1 -1
- package/lib/rest-express/endpoints/password/verify.js +18 -18
- package/lib/rest-express/endpoints/password/verify.js.map +1 -1
- package/lib/rest-express/endpoints/put-user-name.js +5 -5
- package/lib/rest-express/endpoints/put-user-name.js.map +1 -1
- package/lib/rest-express/endpoints/refresh-access-token.js +4 -4
- package/lib/rest-express/endpoints/refresh-access-token.js.map +1 -1
- package/lib/rest-express/endpoints/service-authenticate.js +9 -14
- package/lib/rest-express/endpoints/service-authenticate.js.map +1 -1
- package/lib/rest-express/endpoints/spaces.js +3 -3
- package/lib/rest-express/endpoints/spaces.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/create-tenant.js +9 -9
- package/lib/rest-express/endpoints/steedos/create-tenant.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/get-tenant.js +5 -5
- package/lib/rest-express/endpoints/steedos/get-tenant.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/settings.js +4 -4
- package/lib/rest-express/endpoints/steedos/settings.js.map +1 -1
- package/lib/rest-express/endpoints/update-session.js +5 -6
- package/lib/rest-express/endpoints/update-session.js.map +1 -1
- package/lib/rest-express/express-middleware.js +0 -4
- package/lib/rest-express/express-middleware.js.map +1 -1
- package/lib/rest-express/user-loader.js +8 -8
- package/lib/rest-express/user-loader.js.map +1 -1
- package/lib/rest-express/utils/get-user-agent.js +0 -1
- package/lib/rest-express/utils/get-user-agent.js.map +1 -1
- package/lib/rest-express/utils/users.js +6 -6
- package/lib/rest-express/utils/users.js.map +1 -1
- package/lib/server/accounts-server.js +76 -159
- package/lib/server/accounts-server.js.map +1 -1
- package/lib/server/utils/email.js +1 -3
- package/lib/server/utils/email.js.map +1 -1
- package/lib/server/utils/get-first-user-email.js +0 -1
- package/lib/server/utils/get-first-user-email.js.map +1 -1
- package/lib/server/utils/tokens.js +0 -11
- package/lib/server/utils/tokens.js.map +1 -1
- package/package.json +6 -6
- package/src/server/accounts-server.ts +1 -0
- package/src/types/types/login-result.ts +1 -0
|
@@ -29,7 +29,7 @@ var defaultOptions = {
|
|
|
29
29
|
caseSensitiveUserName: true,
|
|
30
30
|
dateProvider: function (date) { return (date ? date.getTime() : Date.now()); },
|
|
31
31
|
};
|
|
32
|
-
var Mongo =
|
|
32
|
+
var Mongo = (function () {
|
|
33
33
|
function Mongo(db, options) {
|
|
34
34
|
this.options = (0, lodash_1.merge)(tslib_1.__assign({}, defaultOptions), options);
|
|
35
35
|
if (!db) {
|
|
@@ -58,7 +58,7 @@ var Mongo = /** @class */ (function () {
|
|
|
58
58
|
else {
|
|
59
59
|
query.is_phone = { $ne: true };
|
|
60
60
|
}
|
|
61
|
-
return [4
|
|
61
|
+
return [4, this.sessionCollection
|
|
62
62
|
.find(query)
|
|
63
63
|
.project({ _id: 1 })
|
|
64
64
|
.toArray()];
|
|
@@ -69,7 +69,7 @@ var Mongo = /** @class */ (function () {
|
|
|
69
69
|
session.id = session._id.toString();
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
return [2
|
|
72
|
+
return [2, sessions];
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
});
|
|
@@ -78,25 +78,25 @@ var Mongo = /** @class */ (function () {
|
|
|
78
78
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
79
79
|
return tslib_1.__generator(this, function (_a) {
|
|
80
80
|
switch (_a.label) {
|
|
81
|
-
case 0: return [4
|
|
81
|
+
case 0: return [4, this.sessionCollection.createIndex("token", {
|
|
82
82
|
unique: true,
|
|
83
83
|
sparse: true,
|
|
84
84
|
})];
|
|
85
85
|
case 1:
|
|
86
86
|
_a.sent();
|
|
87
|
-
return [4
|
|
87
|
+
return [4, this.collection.createIndex("username", {
|
|
88
88
|
unique: true,
|
|
89
89
|
sparse: true,
|
|
90
90
|
})];
|
|
91
91
|
case 2:
|
|
92
92
|
_a.sent();
|
|
93
|
-
return [4
|
|
93
|
+
return [4, this.collection.createIndex("emails.address", {
|
|
94
94
|
unique: true,
|
|
95
95
|
sparse: true,
|
|
96
96
|
})];
|
|
97
97
|
case 3:
|
|
98
98
|
_a.sent();
|
|
99
|
-
return [2
|
|
99
|
+
return [2];
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
});
|
|
@@ -123,9 +123,9 @@ var Mongo = /** @class */ (function () {
|
|
|
123
123
|
{ address: email.toLowerCase(), verified: email_verified },
|
|
124
124
|
];
|
|
125
125
|
}
|
|
126
|
-
if (!mobile) return [3
|
|
126
|
+
if (!mobile) return [3, 2];
|
|
127
127
|
user.mobile = mobile;
|
|
128
|
-
return [4
|
|
128
|
+
return [4, this.getEncryptedSpaceUserFieldValue(mobile, 'mobile')];
|
|
129
129
|
case 1:
|
|
130
130
|
encryptedMobile = _c.sent();
|
|
131
131
|
if (encryptedMobile) {
|
|
@@ -134,8 +134,8 @@ var Mongo = /** @class */ (function () {
|
|
|
134
134
|
user.mobile_verified = mobile_verified;
|
|
135
135
|
_c.label = 2;
|
|
136
136
|
case 2:
|
|
137
|
-
if (!user.name) return [3
|
|
138
|
-
return [4
|
|
137
|
+
if (!user.name) return [3, 4];
|
|
138
|
+
return [4, this.getEncryptedSpaceUserFieldValue(user.name, 'name')];
|
|
139
139
|
case 3:
|
|
140
140
|
encryptedName = _c.sent();
|
|
141
141
|
if (encryptedName) {
|
|
@@ -147,10 +147,10 @@ var Mongo = /** @class */ (function () {
|
|
|
147
147
|
user._id = this.options.idProvider();
|
|
148
148
|
}
|
|
149
149
|
user.steedos_id = user._id;
|
|
150
|
-
return [4
|
|
150
|
+
return [4, this.collection.insertOne(user)];
|
|
151
151
|
case 5:
|
|
152
152
|
ret = _c.sent();
|
|
153
|
-
return [2
|
|
153
|
+
return [2, user._id];
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
});
|
|
@@ -164,13 +164,13 @@ var Mongo = /** @class */ (function () {
|
|
|
164
164
|
id = this.options.convertUserIdToMongoObjectId
|
|
165
165
|
? toMongoID(userId)
|
|
166
166
|
: userId;
|
|
167
|
-
return [4
|
|
167
|
+
return [4, this.collection.findOne({ _id: id })];
|
|
168
168
|
case 1:
|
|
169
169
|
user = _a.sent();
|
|
170
170
|
if (user) {
|
|
171
171
|
user.id = user._id.toString();
|
|
172
172
|
}
|
|
173
|
-
return [2
|
|
173
|
+
return [2, user];
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
});
|
|
@@ -180,7 +180,7 @@ var Mongo = /** @class */ (function () {
|
|
|
180
180
|
var user;
|
|
181
181
|
return tslib_1.__generator(this, function (_a) {
|
|
182
182
|
switch (_a.label) {
|
|
183
|
-
case 0: return [4
|
|
183
|
+
case 0: return [4, this.collection.findOne({
|
|
184
184
|
email: email.toLowerCase(),
|
|
185
185
|
})];
|
|
186
186
|
case 1:
|
|
@@ -188,7 +188,7 @@ var Mongo = /** @class */ (function () {
|
|
|
188
188
|
if (user) {
|
|
189
189
|
user.id = user._id.toString();
|
|
190
190
|
}
|
|
191
|
-
return [2
|
|
191
|
+
return [2, user];
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
});
|
|
@@ -202,19 +202,19 @@ var Mongo = /** @class */ (function () {
|
|
|
202
202
|
selector = {
|
|
203
203
|
mobile: mobile,
|
|
204
204
|
};
|
|
205
|
-
return [4
|
|
205
|
+
return [4, this.getEncryptedSpaceUserFieldValue(mobile, 'mobile')];
|
|
206
206
|
case 1:
|
|
207
207
|
encryptedMobile = _a.sent();
|
|
208
208
|
if (encryptedMobile) {
|
|
209
209
|
selector.mobile = encryptedMobile;
|
|
210
210
|
}
|
|
211
|
-
return [4
|
|
211
|
+
return [4, this.collection.findOne(selector)];
|
|
212
212
|
case 2:
|
|
213
213
|
user = _a.sent();
|
|
214
214
|
if (user) {
|
|
215
215
|
user.id = user._id.toString();
|
|
216
216
|
}
|
|
217
|
-
return [2
|
|
217
|
+
return [2, user];
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
});
|
|
@@ -230,13 +230,13 @@ var Mongo = /** @class */ (function () {
|
|
|
230
230
|
: {
|
|
231
231
|
$where: "obj.username && (obj.username.toLowerCase() === \"".concat(username.toLowerCase(), "\")"),
|
|
232
232
|
};
|
|
233
|
-
return [4
|
|
233
|
+
return [4, this.collection.findOne(filter)];
|
|
234
234
|
case 1:
|
|
235
235
|
user = _a.sent();
|
|
236
236
|
if (user) {
|
|
237
237
|
user.id = user._id.toString();
|
|
238
238
|
}
|
|
239
|
-
return [2
|
|
239
|
+
return [2, user];
|
|
240
240
|
}
|
|
241
241
|
});
|
|
242
242
|
});
|
|
@@ -246,13 +246,13 @@ var Mongo = /** @class */ (function () {
|
|
|
246
246
|
var user;
|
|
247
247
|
return tslib_1.__generator(this, function (_a) {
|
|
248
248
|
switch (_a.label) {
|
|
249
|
-
case 0: return [4
|
|
249
|
+
case 0: return [4, this.findUserById(userId)];
|
|
250
250
|
case 1:
|
|
251
251
|
user = _a.sent();
|
|
252
252
|
if (user) {
|
|
253
|
-
return [2
|
|
253
|
+
return [2, (0, lodash_1.get)(user, "services.password.bcrypt")];
|
|
254
254
|
}
|
|
255
|
-
return [2
|
|
255
|
+
return [2, null];
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
});
|
|
@@ -262,7 +262,7 @@ var Mongo = /** @class */ (function () {
|
|
|
262
262
|
var user;
|
|
263
263
|
return tslib_1.__generator(this, function (_a) {
|
|
264
264
|
switch (_a.label) {
|
|
265
|
-
case 0: return [4
|
|
265
|
+
case 0: return [4, this.collection.findOne({
|
|
266
266
|
"services.email.verificationTokens.token": token,
|
|
267
267
|
})];
|
|
268
268
|
case 1:
|
|
@@ -270,7 +270,7 @@ var Mongo = /** @class */ (function () {
|
|
|
270
270
|
if (user) {
|
|
271
271
|
user.id = user._id.toString();
|
|
272
272
|
}
|
|
273
|
-
return [2
|
|
273
|
+
return [2, user];
|
|
274
274
|
}
|
|
275
275
|
});
|
|
276
276
|
});
|
|
@@ -280,7 +280,7 @@ var Mongo = /** @class */ (function () {
|
|
|
280
280
|
var user;
|
|
281
281
|
return tslib_1.__generator(this, function (_a) {
|
|
282
282
|
switch (_a.label) {
|
|
283
|
-
case 0: return [4
|
|
283
|
+
case 0: return [4, this.collection.findOne({
|
|
284
284
|
"services.password.reset.token": token,
|
|
285
285
|
})];
|
|
286
286
|
case 1:
|
|
@@ -288,7 +288,7 @@ var Mongo = /** @class */ (function () {
|
|
|
288
288
|
if (user) {
|
|
289
289
|
user.id = user._id.toString();
|
|
290
290
|
}
|
|
291
|
-
return [2
|
|
291
|
+
return [2, user];
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
294
|
});
|
|
@@ -299,7 +299,7 @@ var Mongo = /** @class */ (function () {
|
|
|
299
299
|
var _a;
|
|
300
300
|
return tslib_1.__generator(this, function (_b) {
|
|
301
301
|
switch (_b.label) {
|
|
302
|
-
case 0: return [4
|
|
302
|
+
case 0: return [4, this.collection.findOne((_a = {},
|
|
303
303
|
_a["services.".concat(serviceName, ".id")] = serviceId,
|
|
304
304
|
_a))];
|
|
305
305
|
case 1:
|
|
@@ -307,23 +307,11 @@ var Mongo = /** @class */ (function () {
|
|
|
307
307
|
if (user) {
|
|
308
308
|
user.id = user._id.toString();
|
|
309
309
|
}
|
|
310
|
-
return [2
|
|
310
|
+
return [2, user];
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
});
|
|
314
314
|
};
|
|
315
|
-
// public async findUserByMobile(mobile: string): Promise<User | null>{
|
|
316
|
-
// if(!/^\+\d+/g.test(mobile)){
|
|
317
|
-
// mobile = "+86" + mobile;
|
|
318
|
-
// }
|
|
319
|
-
// const user = await this.collection.findOne({
|
|
320
|
-
// 'phone.number': mobile,
|
|
321
|
-
// });
|
|
322
|
-
// if (user) {
|
|
323
|
-
// user.id = user._id.toString();
|
|
324
|
-
// }
|
|
325
|
-
// return user;
|
|
326
|
-
// }
|
|
327
315
|
Mongo.prototype.addEmail = function (userId, newEmail, verified) {
|
|
328
316
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
329
317
|
var id, ret;
|
|
@@ -334,7 +322,7 @@ var Mongo = /** @class */ (function () {
|
|
|
334
322
|
id = this.options.convertUserIdToMongoObjectId
|
|
335
323
|
? toMongoID(userId)
|
|
336
324
|
: userId;
|
|
337
|
-
return [4
|
|
325
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
338
326
|
$addToSet: {
|
|
339
327
|
emails: {
|
|
340
328
|
address: newEmail.toLowerCase(),
|
|
@@ -350,7 +338,7 @@ var Mongo = /** @class */ (function () {
|
|
|
350
338
|
if (ret.matchedCount === 0) {
|
|
351
339
|
throw new Error("User not found");
|
|
352
340
|
}
|
|
353
|
-
return [2
|
|
341
|
+
return [2];
|
|
354
342
|
}
|
|
355
343
|
});
|
|
356
344
|
});
|
|
@@ -365,7 +353,7 @@ var Mongo = /** @class */ (function () {
|
|
|
365
353
|
id = this.options.convertUserIdToMongoObjectId
|
|
366
354
|
? toMongoID(userId)
|
|
367
355
|
: userId;
|
|
368
|
-
return [4
|
|
356
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
369
357
|
$pull: { emails: { address: email.toLowerCase() } },
|
|
370
358
|
$set: (_a = {},
|
|
371
359
|
_a[this.options.timestamps.updatedAt] = this.options.dateProvider(),
|
|
@@ -376,7 +364,7 @@ var Mongo = /** @class */ (function () {
|
|
|
376
364
|
if (ret.matchedCount === 0) {
|
|
377
365
|
throw new Error("User not found");
|
|
378
366
|
}
|
|
379
|
-
return [2
|
|
367
|
+
return [2];
|
|
380
368
|
}
|
|
381
369
|
});
|
|
382
370
|
});
|
|
@@ -391,7 +379,7 @@ var Mongo = /** @class */ (function () {
|
|
|
391
379
|
id = this.options.convertUserIdToMongoObjectId
|
|
392
380
|
? toMongoID(userId)
|
|
393
381
|
: userId;
|
|
394
|
-
return [4
|
|
382
|
+
return [4, this.collection.updateOne({ _id: id, email: email }, {
|
|
395
383
|
$set: (_a = {
|
|
396
384
|
email_verified: true
|
|
397
385
|
},
|
|
@@ -403,7 +391,7 @@ var Mongo = /** @class */ (function () {
|
|
|
403
391
|
})];
|
|
404
392
|
case 1:
|
|
405
393
|
ret = _b.sent();
|
|
406
|
-
return [4
|
|
394
|
+
return [4, this.spaceUserCollection.updateMany({ user: id }, {
|
|
407
395
|
$set: {
|
|
408
396
|
email_verified: true,
|
|
409
397
|
modified: this.options.dateProvider(),
|
|
@@ -415,12 +403,11 @@ var Mongo = /** @class */ (function () {
|
|
|
415
403
|
if (ret.matchedCount === 0) {
|
|
416
404
|
throw new Error("User not found");
|
|
417
405
|
}
|
|
418
|
-
return [2
|
|
406
|
+
return [2];
|
|
419
407
|
}
|
|
420
408
|
});
|
|
421
409
|
});
|
|
422
410
|
};
|
|
423
|
-
// 如果开启了加密功能,则获取加密后的字段值
|
|
424
411
|
Mongo.prototype.getEncryptedSpaceUserFieldValue = function (value, fieldName) {
|
|
425
412
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
426
413
|
var objectql, objFields, datasource, encryptedValue;
|
|
@@ -428,19 +415,19 @@ var Mongo = /** @class */ (function () {
|
|
|
428
415
|
switch (_a.label) {
|
|
429
416
|
case 0:
|
|
430
417
|
objectql = require('@steedos/objectql');
|
|
431
|
-
return [4
|
|
418
|
+
return [4, objectql.getObject('space_users').getFields()];
|
|
432
419
|
case 1:
|
|
433
420
|
objFields = _a.sent();
|
|
434
|
-
if (!objFields[fieldName].enable_encryption) return [3
|
|
421
|
+
if (!objFields[fieldName].enable_encryption) return [3, 3];
|
|
435
422
|
datasource = (0, objectql_1.getDataSource)('default');
|
|
436
|
-
return [4
|
|
423
|
+
return [4, datasource.adapter.encryptValue(value)];
|
|
437
424
|
case 2:
|
|
438
425
|
encryptedValue = _a.sent();
|
|
439
426
|
if (encryptedValue) {
|
|
440
|
-
return [2
|
|
427
|
+
return [2, encryptedValue];
|
|
441
428
|
}
|
|
442
429
|
_a.label = 3;
|
|
443
|
-
case 3: return [2
|
|
430
|
+
case 3: return [2];
|
|
444
431
|
}
|
|
445
432
|
});
|
|
446
433
|
});
|
|
@@ -455,10 +442,10 @@ var Mongo = /** @class */ (function () {
|
|
|
455
442
|
id = this.options.convertUserIdToMongoObjectId
|
|
456
443
|
? toMongoID(userId)
|
|
457
444
|
: userId;
|
|
458
|
-
return [4
|
|
445
|
+
return [4, this.getEncryptedSpaceUserFieldValue(mobile, 'mobile')];
|
|
459
446
|
case 1:
|
|
460
447
|
encryptedMobile = _b.sent();
|
|
461
|
-
return [4
|
|
448
|
+
return [4, this.collection.updateOne({ _id: id, mobile: encryptedMobile || mobile }, {
|
|
462
449
|
$set: (_a = {
|
|
463
450
|
mobile_verified: true
|
|
464
451
|
},
|
|
@@ -470,7 +457,7 @@ var Mongo = /** @class */ (function () {
|
|
|
470
457
|
})];
|
|
471
458
|
case 2:
|
|
472
459
|
ret = _b.sent();
|
|
473
|
-
return [4
|
|
460
|
+
return [4, this.spaceUserCollection.updateMany({ user: id }, {
|
|
474
461
|
$set: {
|
|
475
462
|
mobile_verified: true,
|
|
476
463
|
modified: this.options.dateProvider(),
|
|
@@ -482,7 +469,7 @@ var Mongo = /** @class */ (function () {
|
|
|
482
469
|
if (ret.matchedCount === 0) {
|
|
483
470
|
throw new Error("User not found");
|
|
484
471
|
}
|
|
485
|
-
return [2
|
|
472
|
+
return [2];
|
|
486
473
|
}
|
|
487
474
|
});
|
|
488
475
|
});
|
|
@@ -497,10 +484,10 @@ var Mongo = /** @class */ (function () {
|
|
|
497
484
|
id = this.options.convertUserIdToMongoObjectId
|
|
498
485
|
? toMongoID(userId)
|
|
499
486
|
: userId;
|
|
500
|
-
return [4
|
|
487
|
+
return [4, this.getEncryptedSpaceUserFieldValue(newMobile, 'mobile')];
|
|
501
488
|
case 1:
|
|
502
489
|
encryptedMobile = (_b.sent()) || newMobile;
|
|
503
|
-
return [4
|
|
490
|
+
return [4, this.collection
|
|
504
491
|
.find({ _id: { $ne: id }, mobile: encryptedMobile })
|
|
505
492
|
.count()];
|
|
506
493
|
case 2:
|
|
@@ -508,11 +495,11 @@ var Mongo = /** @class */ (function () {
|
|
|
508
495
|
if (existed > 0) {
|
|
509
496
|
throw new Error("该手机号已被其他用户注册");
|
|
510
497
|
}
|
|
511
|
-
return [4
|
|
498
|
+
return [4, this.collection.findOne({ _id: id }, { projection: { mobile: 1 } })];
|
|
512
499
|
case 3:
|
|
513
500
|
user = _b.sent();
|
|
514
|
-
if (!(user && user.mobile != newMobile)) return [3
|
|
515
|
-
return [4
|
|
501
|
+
if (!(user && user.mobile != newMobile)) return [3, 6];
|
|
502
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
516
503
|
$set: (_a = {
|
|
517
504
|
mobile: encryptedMobile
|
|
518
505
|
},
|
|
@@ -524,7 +511,7 @@ var Mongo = /** @class */ (function () {
|
|
|
524
511
|
})];
|
|
525
512
|
case 4:
|
|
526
513
|
ret = _b.sent();
|
|
527
|
-
return [4
|
|
514
|
+
return [4, this.spaceUserCollection.updateMany({ user: id }, {
|
|
528
515
|
$set: {
|
|
529
516
|
mobile: encryptedMobile,
|
|
530
517
|
modified: this.options.dateProvider(),
|
|
@@ -538,7 +525,7 @@ var Mongo = /** @class */ (function () {
|
|
|
538
525
|
if (!user) {
|
|
539
526
|
throw new Error("User not found");
|
|
540
527
|
}
|
|
541
|
-
return [2
|
|
528
|
+
return [2];
|
|
542
529
|
}
|
|
543
530
|
});
|
|
544
531
|
});
|
|
@@ -553,7 +540,7 @@ var Mongo = /** @class */ (function () {
|
|
|
553
540
|
id = this.options.convertUserIdToMongoObjectId
|
|
554
541
|
? toMongoID(userId)
|
|
555
542
|
: userId;
|
|
556
|
-
return [4
|
|
543
|
+
return [4, this.collection
|
|
557
544
|
.find({ _id: { $ne: id }, email: newEmail })
|
|
558
545
|
.count()];
|
|
559
546
|
case 1:
|
|
@@ -561,11 +548,11 @@ var Mongo = /** @class */ (function () {
|
|
|
561
548
|
if (existed > 0) {
|
|
562
549
|
throw new Error("该邮箱已被其他用户注册");
|
|
563
550
|
}
|
|
564
|
-
return [4
|
|
551
|
+
return [4, this.collection.findOne({ _id: id }, { projection: { email: 1 } })];
|
|
565
552
|
case 2:
|
|
566
553
|
user = _b.sent();
|
|
567
|
-
if (!(user && user.email != newEmail)) return [3
|
|
568
|
-
return [4
|
|
554
|
+
if (!(user && user.email != newEmail)) return [3, 5];
|
|
555
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
569
556
|
$set: (_a = {
|
|
570
557
|
email: newEmail
|
|
571
558
|
},
|
|
@@ -577,7 +564,7 @@ var Mongo = /** @class */ (function () {
|
|
|
577
564
|
})];
|
|
578
565
|
case 3:
|
|
579
566
|
ret = _b.sent();
|
|
580
|
-
return [4
|
|
567
|
+
return [4, this.spaceUserCollection.updateMany({ user: id }, {
|
|
581
568
|
$set: {
|
|
582
569
|
email: newEmail,
|
|
583
570
|
modified: this.options.dateProvider(),
|
|
@@ -591,7 +578,7 @@ var Mongo = /** @class */ (function () {
|
|
|
591
578
|
if (!user) {
|
|
592
579
|
throw new Error("User not found");
|
|
593
580
|
}
|
|
594
|
-
return [2
|
|
581
|
+
return [2];
|
|
595
582
|
}
|
|
596
583
|
});
|
|
597
584
|
});
|
|
@@ -606,7 +593,7 @@ var Mongo = /** @class */ (function () {
|
|
|
606
593
|
id = this.options.convertUserIdToMongoObjectId
|
|
607
594
|
? toMongoID(userId)
|
|
608
595
|
: userId;
|
|
609
|
-
return [4
|
|
596
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
610
597
|
$set: (_a = {
|
|
611
598
|
username: newUsername
|
|
612
599
|
},
|
|
@@ -618,7 +605,7 @@ var Mongo = /** @class */ (function () {
|
|
|
618
605
|
if (ret.matchedCount === 0) {
|
|
619
606
|
throw new Error("User not found");
|
|
620
607
|
}
|
|
621
|
-
return [2
|
|
608
|
+
return [2];
|
|
622
609
|
}
|
|
623
610
|
});
|
|
624
611
|
});
|
|
@@ -633,7 +620,7 @@ var Mongo = /** @class */ (function () {
|
|
|
633
620
|
id = this.options.convertUserIdToMongoObjectId
|
|
634
621
|
? toMongoID(userId)
|
|
635
622
|
: userId;
|
|
636
|
-
return [4
|
|
623
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
637
624
|
$set: (_a = {
|
|
638
625
|
"services.password.bcrypt": newPassword
|
|
639
626
|
},
|
|
@@ -651,7 +638,7 @@ var Mongo = /** @class */ (function () {
|
|
|
651
638
|
if (ret.matchedCount === 0) {
|
|
652
639
|
throw new Error("User not found");
|
|
653
640
|
}
|
|
654
|
-
return [2
|
|
641
|
+
return [2];
|
|
655
642
|
}
|
|
656
643
|
});
|
|
657
644
|
});
|
|
@@ -666,7 +653,7 @@ var Mongo = /** @class */ (function () {
|
|
|
666
653
|
id = this.options.convertUserIdToMongoObjectId
|
|
667
654
|
? toMongoID(userId)
|
|
668
655
|
: userId;
|
|
669
|
-
return [4
|
|
656
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
670
657
|
$set: (_a = {},
|
|
671
658
|
_a["services.".concat(serviceName)] = service,
|
|
672
659
|
_a[this.options.timestamps.updatedAt] = this.options.dateProvider(),
|
|
@@ -674,7 +661,7 @@ var Mongo = /** @class */ (function () {
|
|
|
674
661
|
})];
|
|
675
662
|
case 1:
|
|
676
663
|
_b.sent();
|
|
677
|
-
return [2
|
|
664
|
+
return [2];
|
|
678
665
|
}
|
|
679
666
|
});
|
|
680
667
|
});
|
|
@@ -689,7 +676,7 @@ var Mongo = /** @class */ (function () {
|
|
|
689
676
|
id = this.options.convertUserIdToMongoObjectId
|
|
690
677
|
? toMongoID(userId)
|
|
691
678
|
: userId;
|
|
692
|
-
return [4
|
|
679
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
693
680
|
$set: (_a = {},
|
|
694
681
|
_a[this.options.timestamps.updatedAt] = this.options.dateProvider(),
|
|
695
682
|
_a),
|
|
@@ -699,7 +686,7 @@ var Mongo = /** @class */ (function () {
|
|
|
699
686
|
})];
|
|
700
687
|
case 1:
|
|
701
688
|
_c.sent();
|
|
702
|
-
return [2
|
|
689
|
+
return [2];
|
|
703
690
|
}
|
|
704
691
|
});
|
|
705
692
|
});
|
|
@@ -714,7 +701,7 @@ var Mongo = /** @class */ (function () {
|
|
|
714
701
|
id = this.options.convertUserIdToMongoObjectId
|
|
715
702
|
? toMongoID(userId)
|
|
716
703
|
: userId;
|
|
717
|
-
return [4
|
|
704
|
+
return [4, this.collection.updateOne({ _id: id }, {
|
|
718
705
|
$set: (_a = {
|
|
719
706
|
deactivated: deactivated
|
|
720
707
|
},
|
|
@@ -723,7 +710,7 @@ var Mongo = /** @class */ (function () {
|
|
|
723
710
|
})];
|
|
724
711
|
case 1:
|
|
725
712
|
_b.sent();
|
|
726
|
-
return [2
|
|
713
|
+
return [2];
|
|
727
714
|
}
|
|
728
715
|
});
|
|
729
716
|
});
|
|
@@ -781,13 +768,13 @@ var Mongo = /** @class */ (function () {
|
|
|
781
768
|
if (this.options.idProvider) {
|
|
782
769
|
session._id = this.options.idProvider();
|
|
783
770
|
}
|
|
784
|
-
return [4
|
|
771
|
+
return [4, this.sessionCollection.insertOne(session)];
|
|
785
772
|
case 1:
|
|
786
773
|
ret = _b.sent();
|
|
787
|
-
return [4
|
|
774
|
+
return [4, this.updateMeteorSession(userId, token, infos)];
|
|
788
775
|
case 2:
|
|
789
776
|
_b.sent();
|
|
790
|
-
return [2
|
|
777
|
+
return [2, ret.insertedId.toString()];
|
|
791
778
|
}
|
|
792
779
|
});
|
|
793
780
|
});
|
|
@@ -812,12 +799,12 @@ var Mongo = /** @class */ (function () {
|
|
|
812
799
|
if (infos.space) {
|
|
813
800
|
_set.space = infos.space;
|
|
814
801
|
}
|
|
815
|
-
return [4
|
|
802
|
+
return [4, this.sessionCollection.updateOne({ _id: _id }, {
|
|
816
803
|
$set: _set,
|
|
817
804
|
})];
|
|
818
805
|
case 1:
|
|
819
806
|
_b.sent();
|
|
820
|
-
return [2
|
|
807
|
+
return [2];
|
|
821
808
|
}
|
|
822
809
|
});
|
|
823
810
|
});
|
|
@@ -832,7 +819,7 @@ var Mongo = /** @class */ (function () {
|
|
|
832
819
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
833
820
|
? toMongoID(sessionId)
|
|
834
821
|
: sessionId;
|
|
835
|
-
return [4
|
|
822
|
+
return [4, this.sessionCollection.updateOne({ _id: _id }, {
|
|
836
823
|
$set: (_a = {
|
|
837
824
|
valid: false
|
|
838
825
|
},
|
|
@@ -841,15 +828,15 @@ var Mongo = /** @class */ (function () {
|
|
|
841
828
|
})];
|
|
842
829
|
case 1:
|
|
843
830
|
_b.sent();
|
|
844
|
-
return [4
|
|
831
|
+
return [4, this.sessionCollection.findOne({
|
|
845
832
|
_id: _id,
|
|
846
833
|
})];
|
|
847
834
|
case 2:
|
|
848
835
|
session = _b.sent();
|
|
849
|
-
return [4
|
|
836
|
+
return [4, this.destroyMeteorToken(session.userId, session.token)];
|
|
850
837
|
case 3:
|
|
851
838
|
_b.sent();
|
|
852
|
-
return [2
|
|
839
|
+
return [2];
|
|
853
840
|
}
|
|
854
841
|
});
|
|
855
842
|
});
|
|
@@ -859,7 +846,7 @@ var Mongo = /** @class */ (function () {
|
|
|
859
846
|
var _a;
|
|
860
847
|
return tslib_1.__generator(this, function (_b) {
|
|
861
848
|
switch (_b.label) {
|
|
862
|
-
case 0: return [4
|
|
849
|
+
case 0: return [4, this.sessionCollection.updateMany({ userId: userId }, {
|
|
863
850
|
$set: (_a = {
|
|
864
851
|
valid: false
|
|
865
852
|
},
|
|
@@ -868,7 +855,7 @@ var Mongo = /** @class */ (function () {
|
|
|
868
855
|
})];
|
|
869
856
|
case 1:
|
|
870
857
|
_b.sent();
|
|
871
|
-
return [2
|
|
858
|
+
return [2];
|
|
872
859
|
}
|
|
873
860
|
});
|
|
874
861
|
});
|
|
@@ -878,13 +865,13 @@ var Mongo = /** @class */ (function () {
|
|
|
878
865
|
var session;
|
|
879
866
|
return tslib_1.__generator(this, function (_a) {
|
|
880
867
|
switch (_a.label) {
|
|
881
|
-
case 0: return [4
|
|
868
|
+
case 0: return [4, this.sessionCollection.findOne({ token: token })];
|
|
882
869
|
case 1:
|
|
883
870
|
session = _a.sent();
|
|
884
871
|
if (session) {
|
|
885
872
|
session.id = session._id.toString();
|
|
886
873
|
}
|
|
887
|
-
return [2
|
|
874
|
+
return [2, session];
|
|
888
875
|
}
|
|
889
876
|
});
|
|
890
877
|
});
|
|
@@ -898,13 +885,13 @@ var Mongo = /** @class */ (function () {
|
|
|
898
885
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
899
886
|
? toMongoID(sessionId)
|
|
900
887
|
: sessionId;
|
|
901
|
-
return [4
|
|
888
|
+
return [4, this.sessionCollection.findOne({ _id: _id })];
|
|
902
889
|
case 1:
|
|
903
890
|
session = _a.sent();
|
|
904
891
|
if (session) {
|
|
905
892
|
session.id = session._id.toString();
|
|
906
893
|
}
|
|
907
|
-
return [2
|
|
894
|
+
return [2, session];
|
|
908
895
|
}
|
|
909
896
|
});
|
|
910
897
|
});
|
|
@@ -918,7 +905,7 @@ var Mongo = /** @class */ (function () {
|
|
|
918
905
|
_id = this.options.convertUserIdToMongoObjectId
|
|
919
906
|
? toMongoID(userId)
|
|
920
907
|
: userId;
|
|
921
|
-
return [4
|
|
908
|
+
return [4, this.collection.updateOne({ _id: _id }, {
|
|
922
909
|
$push: {
|
|
923
910
|
"services.email.verificationTokens": {
|
|
924
911
|
token: token,
|
|
@@ -929,7 +916,7 @@ var Mongo = /** @class */ (function () {
|
|
|
929
916
|
})];
|
|
930
917
|
case 1:
|
|
931
918
|
_a.sent();
|
|
932
|
-
return [2
|
|
919
|
+
return [2];
|
|
933
920
|
}
|
|
934
921
|
});
|
|
935
922
|
});
|
|
@@ -943,7 +930,7 @@ var Mongo = /** @class */ (function () {
|
|
|
943
930
|
_id = this.options.convertUserIdToMongoObjectId
|
|
944
931
|
? toMongoID(userId)
|
|
945
932
|
: userId;
|
|
946
|
-
return [4
|
|
933
|
+
return [4, this.collection.updateOne({ _id: _id }, {
|
|
947
934
|
$push: {
|
|
948
935
|
"services.password.reset": {
|
|
949
936
|
token: token,
|
|
@@ -955,7 +942,7 @@ var Mongo = /** @class */ (function () {
|
|
|
955
942
|
})];
|
|
956
943
|
case 1:
|
|
957
944
|
_a.sent();
|
|
958
|
-
return [2
|
|
945
|
+
return [2];
|
|
959
946
|
}
|
|
960
947
|
});
|
|
961
948
|
});
|
|
@@ -964,10 +951,10 @@ var Mongo = /** @class */ (function () {
|
|
|
964
951
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
965
952
|
return tslib_1.__generator(this, function (_a) {
|
|
966
953
|
switch (_a.label) {
|
|
967
|
-
case 0: return [4
|
|
954
|
+
case 0: return [4, this.setPassword(userId, newPassword)];
|
|
968
955
|
case 1:
|
|
969
956
|
_a.sent();
|
|
970
|
-
return [2
|
|
957
|
+
return [2];
|
|
971
958
|
}
|
|
972
959
|
});
|
|
973
960
|
});
|
|
@@ -988,11 +975,11 @@ var Mongo = /** @class */ (function () {
|
|
|
988
975
|
if (owner) {
|
|
989
976
|
query.owner = owner;
|
|
990
977
|
}
|
|
991
|
-
return [4
|
|
978
|
+
return [4, this.codeCollection.findOne(query)];
|
|
992
979
|
case 1:
|
|
993
980
|
record = _b.sent();
|
|
994
|
-
if (!record) return [3
|
|
995
|
-
return [3
|
|
981
|
+
if (!record) return [3, 2];
|
|
982
|
+
return [3, 4];
|
|
996
983
|
case 2:
|
|
997
984
|
doc = (_a = {
|
|
998
985
|
name: name,
|
|
@@ -1005,13 +992,13 @@ var Mongo = /** @class */ (function () {
|
|
|
1005
992
|
if (this.options.idProvider) {
|
|
1006
993
|
doc._id = this.options.idProvider();
|
|
1007
994
|
}
|
|
1008
|
-
return [4
|
|
995
|
+
return [4, this.codeCollection.insertOne(doc)];
|
|
1009
996
|
case 3:
|
|
1010
997
|
result = _b.sent();
|
|
1011
998
|
record = result.ops[0];
|
|
1012
999
|
;
|
|
1013
1000
|
_b.label = 4;
|
|
1014
|
-
case 4: return [2
|
|
1001
|
+
case 4: return [2, record];
|
|
1015
1002
|
}
|
|
1016
1003
|
});
|
|
1017
1004
|
});
|
|
@@ -1023,23 +1010,23 @@ var Mongo = /** @class */ (function () {
|
|
|
1023
1010
|
switch (_a.label) {
|
|
1024
1011
|
case 0:
|
|
1025
1012
|
foundedUser = null;
|
|
1026
|
-
if (!user.email) return [3
|
|
1027
|
-
return [4
|
|
1013
|
+
if (!user.email) return [3, 2];
|
|
1014
|
+
return [4, this.findUserByEmail(user.email)];
|
|
1028
1015
|
case 1:
|
|
1029
1016
|
foundedUser = _a.sent();
|
|
1030
|
-
return [3
|
|
1017
|
+
return [3, 4];
|
|
1031
1018
|
case 2:
|
|
1032
|
-
if (!user.mobile) return [3
|
|
1033
|
-
return [4
|
|
1019
|
+
if (!user.mobile) return [3, 4];
|
|
1020
|
+
return [4, this.findUserByMobile(user.mobile)];
|
|
1034
1021
|
case 3:
|
|
1035
1022
|
foundedUser = _a.sent();
|
|
1036
1023
|
_a.label = 4;
|
|
1037
1024
|
case 4:
|
|
1038
1025
|
owner = foundedUser ? foundedUser.id : null;
|
|
1039
|
-
return [4
|
|
1026
|
+
return [4, this.applyCode(user.email ? user.email : user.mobile, owner, code, options.MAX_FAILURE_COUNT, options.EFFECTIVE_TIME)];
|
|
1040
1027
|
case 5:
|
|
1041
1028
|
ret = _a.sent();
|
|
1042
|
-
return [2
|
|
1029
|
+
return [2, ret];
|
|
1043
1030
|
}
|
|
1044
1031
|
});
|
|
1045
1032
|
});
|
|
@@ -1057,14 +1044,14 @@ var Mongo = /** @class */ (function () {
|
|
|
1057
1044
|
verifiedAt: null,
|
|
1058
1045
|
expiredAt: { $gt: now },
|
|
1059
1046
|
};
|
|
1060
|
-
return [4
|
|
1047
|
+
return [4, this.codeCollection.findOne(query)];
|
|
1061
1048
|
case 1:
|
|
1062
1049
|
result = _a.sent();
|
|
1063
|
-
if (!result) return [3
|
|
1064
|
-
return [4
|
|
1050
|
+
if (!result) return [3, 3];
|
|
1051
|
+
return [4, this.codeCollection.updateOne({ _id: result._id }, { $set: { verifiedAt: now } })];
|
|
1065
1052
|
case 2:
|
|
1066
1053
|
_a.sent();
|
|
1067
|
-
return [2
|
|
1054
|
+
return [2, result];
|
|
1068
1055
|
case 3: throw new Error("accounts.invalidCode");
|
|
1069
1056
|
}
|
|
1070
1057
|
});
|
|
@@ -1083,14 +1070,14 @@ var Mongo = /** @class */ (function () {
|
|
|
1083
1070
|
verifiedAt: null,
|
|
1084
1071
|
expiredAt: { $gt: now },
|
|
1085
1072
|
};
|
|
1086
|
-
return [4
|
|
1073
|
+
return [4, this.codeCollection.findOne(query)];
|
|
1087
1074
|
case 1:
|
|
1088
1075
|
result = _a.sent();
|
|
1089
|
-
if (!result) return [3
|
|
1090
|
-
return [4
|
|
1076
|
+
if (!result) return [3, 3];
|
|
1077
|
+
return [4, this.codeCollection.updateOne({ _id: result._id }, { $set: { verifiedAt: now } })];
|
|
1091
1078
|
case 2:
|
|
1092
1079
|
_a.sent();
|
|
1093
|
-
return [2
|
|
1080
|
+
return [2, result];
|
|
1094
1081
|
case 3:
|
|
1095
1082
|
console.log("verifyCodeByOwner throw new Error accounts.invalidCode");
|
|
1096
1083
|
throw new Error("accounts.invalidCode");
|
|
@@ -1110,13 +1097,13 @@ var Mongo = /** @class */ (function () {
|
|
|
1110
1097
|
else if (user.mobile)
|
|
1111
1098
|
name = user.mobile;
|
|
1112
1099
|
if (!name)
|
|
1113
|
-
return [2
|
|
1114
|
-
return [4
|
|
1100
|
+
return [2, false];
|
|
1101
|
+
return [4, this.verifyCodeByName(name, code)];
|
|
1115
1102
|
case 1:
|
|
1116
1103
|
record = _a.sent();
|
|
1117
1104
|
if (!record)
|
|
1118
|
-
return [2
|
|
1119
|
-
return [2
|
|
1105
|
+
return [2, false];
|
|
1106
|
+
return [2, true];
|
|
1120
1107
|
}
|
|
1121
1108
|
});
|
|
1122
1109
|
});
|
|
@@ -1128,44 +1115,44 @@ var Mongo = /** @class */ (function () {
|
|
|
1128
1115
|
switch (_a.label) {
|
|
1129
1116
|
case 0:
|
|
1130
1117
|
foundedUser = null;
|
|
1131
|
-
if (!user.email) return [3
|
|
1132
|
-
return [4
|
|
1118
|
+
if (!user.email) return [3, 2];
|
|
1119
|
+
return [4, this.findUserByEmail(user.email)];
|
|
1133
1120
|
case 1:
|
|
1134
1121
|
foundedUser = _a.sent();
|
|
1135
|
-
return [3
|
|
1122
|
+
return [3, 4];
|
|
1136
1123
|
case 2:
|
|
1137
|
-
if (!user.mobile) return [3
|
|
1138
|
-
return [4
|
|
1124
|
+
if (!user.mobile) return [3, 4];
|
|
1125
|
+
return [4, this.findUserByMobile(user.mobile)];
|
|
1139
1126
|
case 3:
|
|
1140
1127
|
foundedUser = _a.sent();
|
|
1141
1128
|
_a.label = 4;
|
|
1142
1129
|
case 4:
|
|
1143
1130
|
if (!foundedUser)
|
|
1144
|
-
return [2
|
|
1131
|
+
return [2, null];
|
|
1145
1132
|
owner = foundedUser.id;
|
|
1146
|
-
return [4
|
|
1133
|
+
return [4, this.verifyCodeByOwner(owner, code)];
|
|
1147
1134
|
case 5:
|
|
1148
1135
|
record = _a.sent();
|
|
1149
1136
|
if (!record)
|
|
1150
|
-
return [2
|
|
1151
|
-
if (!(user.email && foundedUser.email_verified != true)) return [3
|
|
1152
|
-
return [4
|
|
1137
|
+
return [2, null];
|
|
1138
|
+
if (!(user.email && foundedUser.email_verified != true)) return [3, 8];
|
|
1139
|
+
return [4, this.verifyEmail(owner, user.email)];
|
|
1153
1140
|
case 6:
|
|
1154
1141
|
_a.sent();
|
|
1155
|
-
return [4
|
|
1142
|
+
return [4, this.findUserById(owner)];
|
|
1156
1143
|
case 7:
|
|
1157
1144
|
foundedUser = _a.sent();
|
|
1158
|
-
return [3
|
|
1145
|
+
return [3, 11];
|
|
1159
1146
|
case 8:
|
|
1160
|
-
if (!(user.mobile && foundedUser.mobile_verified != true)) return [3
|
|
1161
|
-
return [4
|
|
1147
|
+
if (!(user.mobile && foundedUser.mobile_verified != true)) return [3, 11];
|
|
1148
|
+
return [4, this.verifyMobile(owner, user.mobile)];
|
|
1162
1149
|
case 9:
|
|
1163
1150
|
_a.sent();
|
|
1164
|
-
return [4
|
|
1151
|
+
return [4, this.findUserById(owner)];
|
|
1165
1152
|
case 10:
|
|
1166
1153
|
foundedUser = _a.sent();
|
|
1167
1154
|
_a.label = 11;
|
|
1168
|
-
case 11: return [2
|
|
1155
|
+
case 11: return [2, foundedUser];
|
|
1169
1156
|
}
|
|
1170
1157
|
});
|
|
1171
1158
|
});
|
|
@@ -1175,7 +1162,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1175
1162
|
var userSpaces, spaceIds, spaces;
|
|
1176
1163
|
return tslib_1.__generator(this, function (_a) {
|
|
1177
1164
|
switch (_a.label) {
|
|
1178
|
-
case 0: return [4
|
|
1165
|
+
case 0: return [4, this.db
|
|
1179
1166
|
.collection("space_users")
|
|
1180
1167
|
.find({ user: userId })
|
|
1181
1168
|
.project({ space: 1 })
|
|
@@ -1183,14 +1170,14 @@ var Mongo = /** @class */ (function () {
|
|
|
1183
1170
|
case 1:
|
|
1184
1171
|
userSpaces = _a.sent();
|
|
1185
1172
|
spaceIds = (0, lodash_1.map)(userSpaces, "space");
|
|
1186
|
-
return [4
|
|
1173
|
+
return [4, this.db
|
|
1187
1174
|
.collection("spaces")
|
|
1188
1175
|
.find({ _id: { $in: spaceIds } })
|
|
1189
1176
|
.project({ name: 1 })
|
|
1190
1177
|
.toArray()];
|
|
1191
1178
|
case 2:
|
|
1192
1179
|
spaces = _a.sent();
|
|
1193
|
-
return [2
|
|
1180
|
+
return [2, spaces];
|
|
1194
1181
|
}
|
|
1195
1182
|
});
|
|
1196
1183
|
});
|
|
@@ -1218,12 +1205,12 @@ var Mongo = /** @class */ (function () {
|
|
|
1218
1205
|
hashedToken.created = new Date();
|
|
1219
1206
|
hashedToken.is_phone = is_phone;
|
|
1220
1207
|
hashedToken.is_tablet = is_tablet;
|
|
1221
|
-
return [4
|
|
1208
|
+
return [4, this.collection.updateOne({ _id: userId }, { $push: {
|
|
1222
1209
|
"services.resume.loginTokens": hashedToken
|
|
1223
1210
|
} })];
|
|
1224
1211
|
case 1:
|
|
1225
1212
|
_a.sent();
|
|
1226
|
-
return [2
|
|
1213
|
+
return [2, true];
|
|
1227
1214
|
}
|
|
1228
1215
|
});
|
|
1229
1216
|
});
|
|
@@ -1240,7 +1227,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1240
1227
|
};
|
|
1241
1228
|
hashedTokenDoc = (0, auth_1.hashStampedToken)(stampedAuthToken);
|
|
1242
1229
|
loginToken = hashedTokenDoc.hashedToken;
|
|
1243
|
-
return [4
|
|
1230
|
+
return [4, this.collection.updateOne({ _id: userId }, {
|
|
1244
1231
|
$pull: {
|
|
1245
1232
|
"services.resume.loginTokens": {
|
|
1246
1233
|
$or: [{ hashedToken: loginToken }, { token: loginToken }],
|
|
@@ -1249,7 +1236,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1249
1236
|
})];
|
|
1250
1237
|
case 1:
|
|
1251
1238
|
_a.sent();
|
|
1252
|
-
return [2
|
|
1239
|
+
return [2, true];
|
|
1253
1240
|
}
|
|
1254
1241
|
});
|
|
1255
1242
|
});
|
|
@@ -1258,8 +1245,8 @@ var Mongo = /** @class */ (function () {
|
|
|
1258
1245
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1259
1246
|
return tslib_1.__generator(this, function (_a) {
|
|
1260
1247
|
switch (_a.label) {
|
|
1261
|
-
case 0: return [4
|
|
1262
|
-
case 1: return [2
|
|
1248
|
+
case 0: return [4, this.inviteCollection.findOne({ _id: id })];
|
|
1249
|
+
case 1: return [2, _a.sent()];
|
|
1263
1250
|
}
|
|
1264
1251
|
});
|
|
1265
1252
|
});
|
|
@@ -1267,7 +1254,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1267
1254
|
Mongo.prototype.updateUser = function (userId, options) {
|
|
1268
1255
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1269
1256
|
return tslib_1.__generator(this, function (_a) {
|
|
1270
|
-
return [2
|
|
1257
|
+
return [2, this.collection.updateOne({ _id: userId }, options)];
|
|
1271
1258
|
});
|
|
1272
1259
|
});
|
|
1273
1260
|
};
|