@accounts/password
Advanced tools
Comparing version 0.30.0-alpha.1 to 0.30.0
@@ -202,16 +202,18 @@ "use strict"; | ||
_a.sent(); | ||
this.server.getHooks().emit(server_1.ServerHooks.ResetPasswordSuccess, user); | ||
if (!(resetTokenRecord.reason === 'enroll')) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.db.verifyEmail(user.id, resetTokenRecord.address)]; | ||
return [4 /*yield*/, this.server.getHooks().emit(server_1.ServerHooks.ResetPasswordSuccess, user)]; | ||
case 4: | ||
_a.sent(); | ||
_a.label = 5; | ||
if (!(resetTokenRecord.reason === 'enroll')) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this.db.verifyEmail(user.id, resetTokenRecord.address)]; | ||
case 5: | ||
if (!this.options.invalidateAllSessionsAfterPasswordReset) return [3 /*break*/, 7]; | ||
_a.sent(); | ||
_a.label = 6; | ||
case 6: | ||
if (!this.options.invalidateAllSessionsAfterPasswordReset) return [3 /*break*/, 8]; | ||
return [4 /*yield*/, this.db.invalidateAllSessions(user.id)]; | ||
case 6: | ||
case 7: | ||
_a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
if (!this.options.notifyUserAfterPasswordChanged) return [3 /*break*/, 9]; | ||
_a.label = 8; | ||
case 8: | ||
if (!this.options.notifyUserAfterPasswordChanged) return [3 /*break*/, 10]; | ||
address = user.emails && user.emails[0].address; | ||
@@ -223,6 +225,6 @@ if (!address) { | ||
return [4 /*yield*/, this.server.options.sendMail(passwordChangedMail)]; | ||
case 8: | ||
case 9: | ||
_a.sent(); | ||
_a.label = 9; | ||
case 9: | ||
_a.label = 10; | ||
case 10: | ||
if (this.options.returnTokensAfterResetPassword) { | ||
@@ -282,16 +284,18 @@ return [2 /*return*/, this.server.loginWithUser(user, infos)]; | ||
_a.sent(); | ||
this.server.getHooks().emit(server_1.ServerHooks.ChangePasswordSuccess, user); | ||
if (!this.options.invalidateAllSessionsAfterPasswordChanged) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.db.invalidateAllSessions(user.id)]; | ||
return [4 /*yield*/, this.server.getHooks().emit(server_1.ServerHooks.ChangePasswordSuccess, user)]; | ||
case 4: | ||
_a.sent(); | ||
_a.label = 5; | ||
if (!this.options.invalidateAllSessionsAfterPasswordChanged) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this.db.invalidateAllSessions(user.id)]; | ||
case 5: | ||
if (!this.options.removeAllResetPasswordTokensAfterPasswordChanged) return [3 /*break*/, 7]; | ||
_a.sent(); | ||
_a.label = 6; | ||
case 6: | ||
if (!this.options.removeAllResetPasswordTokensAfterPasswordChanged) return [3 /*break*/, 8]; | ||
return [4 /*yield*/, this.db.removeAllResetPasswordTokens(user.id)]; | ||
case 6: | ||
case 7: | ||
_a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
if (!this.options.notifyUserAfterPasswordChanged) return [3 /*break*/, 9]; | ||
_a.label = 8; | ||
case 8: | ||
if (!this.options.notifyUserAfterPasswordChanged) return [3 /*break*/, 10]; | ||
address = user.emails && user.emails[0].address; | ||
@@ -303,6 +307,6 @@ if (!address) { | ||
return [4 /*yield*/, this.server.options.sendMail(passwordChangedMail)]; | ||
case 8: | ||
case 9: | ||
_a.sent(); | ||
_a.label = 9; | ||
case 9: return [2 /*return*/]; | ||
_a.label = 10; | ||
case 10: return [2 /*return*/]; | ||
} | ||
@@ -334,6 +338,2 @@ }); | ||
if (!user) { | ||
// To prevent user enumeration we fail silently | ||
if (this.server.options.ambiguousErrorMessages) { | ||
return [2 /*return*/]; | ||
} | ||
throw new server_1.AccountsJsError(this.options.errors.userNotFound, errors_1.SendVerificationEmailErrors.UserNotFound); | ||
@@ -379,6 +379,2 @@ } | ||
if (!user) { | ||
// To prevent user enumeration we fail silently | ||
if (this.server.options.ambiguousErrorMessages) { | ||
return [2 /*return*/]; | ||
} | ||
throw new server_1.AccountsJsError(this.options.errors.userNotFound, errors_1.SendResetPasswordEmailErrors.UserNotFound); | ||
@@ -444,3 +440,3 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _a, _b, _c, _d, userId_1, e_1; | ||
var _a, _b, _c, _d, userId, userRecord, e_1; | ||
var _this = this; | ||
@@ -506,29 +502,28 @@ return tslib_1.__generator(this, function (_e) { | ||
case 10: | ||
_e.trys.push([10, 12, , 14]); | ||
_e.trys.push([10, 14, , 16]); | ||
return [4 /*yield*/, this.db.createUser(user)]; | ||
case 11: | ||
userId_1 = _e.sent(); | ||
userId = _e.sent(); | ||
return [4 /*yield*/, this.db.findUserById(userId)]; | ||
case 12: | ||
userRecord = (_e.sent()); | ||
return [4 /*yield*/, this.server.getHooks().emit(server_1.ServerHooks.CreateUserSuccess, userRecord)]; | ||
case 13: | ||
_e.sent(); | ||
lodash_1.defer(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var userRecord; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (this.options.sendVerificationEmailAfterSignup && user.email) | ||
this.sendVerificationEmail(user.email); | ||
return [4 /*yield*/, this.db.findUserById(userId_1)]; | ||
case 1: | ||
userRecord = (_a.sent()); | ||
this.server.getHooks().emit(server_1.ServerHooks.CreateUserSuccess, userRecord); | ||
return [2 /*return*/]; | ||
if (this.options.sendVerificationEmailAfterSignup && user.email) { | ||
this.sendVerificationEmail(user.email); | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
}); }); | ||
return [2 /*return*/, userId_1]; | ||
case 12: | ||
return [2 /*return*/, userId]; | ||
case 14: | ||
e_1 = _e.sent(); | ||
return [4 /*yield*/, this.server.getHooks().emit(server_1.ServerHooks.CreateUserError, user)]; | ||
case 13: | ||
case 15: | ||
_e.sent(); | ||
throw e_1; | ||
case 14: return [2 /*return*/]; | ||
case 16: return [2 /*return*/]; | ||
} | ||
@@ -535,0 +530,0 @@ }); |
{ | ||
"name": "@accounts/password", | ||
"version": "0.30.0-alpha.1", | ||
"version": "0.30.0", | ||
"license": "MIT", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"prepublishOnly": "yarn compile", | ||
"testonly": "jest", | ||
"testonly": "jest --coverage", | ||
"coverage": "jest --coverage" | ||
@@ -26,15 +26,15 @@ }, | ||
"dependencies": { | ||
"@accounts/two-factor": "^0.30.0-alpha.1", | ||
"@accounts/two-factor": "^0.30.0", | ||
"bcryptjs": "^2.4.3", | ||
"lodash": "^4.17.20", | ||
"tslib": "2.0.1" | ||
"lodash": "^4.17.15", | ||
"tslib": "2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@accounts/server": "^0.30.0-alpha.1", | ||
"@accounts/types": "^0.30.0-alpha.1", | ||
"@accounts/server": "^0.30.0", | ||
"@accounts/types": "^0.30.0", | ||
"@types/bcryptjs": "2.4.2", | ||
"@types/jest": "26.0.9", | ||
"@types/lodash": "4.14.159", | ||
"@types/node": "14.0.27", | ||
"jest": "26.3.0", | ||
"@types/jest": "25.2.3", | ||
"@types/lodash": "4.14.157", | ||
"@types/node": "14.0.14", | ||
"jest": "26.0.1", | ||
"rimraf": "3.0.2" | ||
@@ -45,3 +45,3 @@ }, | ||
}, | ||
"gitHead": "eb9750193707aecb771b63d29540a8b6c316ebe0" | ||
"gitHead": "a883d3b90c481e9c73a7655ef2aadac092fc6b0e" | ||
} |
@@ -353,3 +353,3 @@ import { trim, isEmpty, pick, isString, isPlainObject, find, includes, defer } from 'lodash'; | ||
this.server.getHooks().emit(ServerHooks.ResetPasswordSuccess, user); | ||
await this.server.getHooks().emit(ServerHooks.ResetPasswordSuccess, user); | ||
@@ -426,3 +426,3 @@ // If user clicked on an enrollment link we can verify his email | ||
this.server.getHooks().emit(ServerHooks.ChangePasswordSuccess, user); | ||
await this.server.getHooks().emit(ServerHooks.ChangePasswordSuccess, user); | ||
@@ -474,6 +474,2 @@ if (this.options.invalidateAllSessionsAfterPasswordChanged) { | ||
if (!user) { | ||
// To prevent user enumeration we fail silently | ||
if (this.server.options.ambiguousErrorMessages) { | ||
return; | ||
} | ||
throw new AccountsJsError( | ||
@@ -527,6 +523,2 @@ this.options.errors.userNotFound, | ||
if (!user) { | ||
// To prevent user enumeration we fail silently | ||
if (this.server.options.ambiguousErrorMessages) { | ||
return; | ||
} | ||
throw new AccountsJsError( | ||
@@ -652,8 +644,9 @@ this.options.errors.userNotFound, | ||
const userRecord = (await this.db.findUserById(userId)) as User; | ||
await this.server.getHooks().emit(ServerHooks.CreateUserSuccess, userRecord); | ||
defer(async () => { | ||
if (this.options.sendVerificationEmailAfterSignup && user.email) | ||
if (this.options.sendVerificationEmailAfterSignup && user.email) { | ||
this.sendVerificationEmail(user.email); | ||
const userRecord = (await this.db.findUserById(userId)) as User; | ||
this.server.getHooks().emit(ServerHooks.CreateUserSuccess, userRecord); | ||
} | ||
}); | ||
@@ -660,0 +653,0 @@ |
Sorry, the diff of this file is not supported yet
117834
2218
- Removedtslib@2.0.1(transitive)
Updated@accounts/two-factor@^0.30.0
Updatedlodash@^4.17.15
Updatedtslib@2.0.0