@accounts/server
Advanced tools
Comparing version 0.0.4-alpha.6d363033 to 0.0.4-alpha.9b2e36fb
@@ -727,3 +727,3 @@ 'use strict'; | ||
var _ref10 = _asyncToGenerator(regeneratorRuntime.mark(function _callee9(token) { | ||
var user, tokenRecord, emailRecord; | ||
var user, verificationTokens, tokenRecord, emailRecord; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
@@ -747,3 +747,4 @@ while (1) { | ||
case 5: | ||
tokenRecord = (0, _lodash.find)(user.services.email.verificationTokens, function (t) { | ||
verificationTokens = (0, _lodash.get)(user, ['services', 'email', 'verificationTokens'], []); | ||
tokenRecord = (0, _lodash.find)(verificationTokens, function (t) { | ||
return t.token === token; | ||
@@ -753,3 +754,3 @@ }); | ||
if (tokenRecord) { | ||
_context9.next = 8; | ||
_context9.next = 9; | ||
break; | ||
@@ -760,3 +761,3 @@ } | ||
case 8: | ||
case 9: | ||
// TODO check time for expiry date | ||
@@ -768,3 +769,3 @@ emailRecord = (0, _lodash.find)(user.emails, function (e) { | ||
if (emailRecord) { | ||
_context9.next = 11; | ||
_context9.next = 12; | ||
break; | ||
@@ -775,7 +776,7 @@ } | ||
case 11: | ||
_context9.next = 13; | ||
return this.db.verifyEmail(user.id, emailRecord); | ||
case 12: | ||
_context9.next = 14; | ||
return this.db.verifyEmail(user.id, emailRecord.address); | ||
case 13: | ||
case 14: | ||
case 'end': | ||
@@ -798,3 +799,3 @@ return _context9.stop(); | ||
var _ref11 = _asyncToGenerator(regeneratorRuntime.mark(function _callee10(token, newPassword) { | ||
var user, resetTokenRecord; | ||
var user, resetTokens, resetTokenRecord, emails; | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
@@ -818,3 +819,4 @@ while (1) { | ||
case 5: | ||
resetTokenRecord = (0, _lodash.find)(user.services.password.resetTokens, function (t) { | ||
resetTokens = (0, _lodash.get)(user, ['services', 'password', 'resetTokens']); | ||
resetTokenRecord = (0, _lodash.find)(resetTokens, function (t) { | ||
return t.token === token; | ||
@@ -824,3 +826,3 @@ }); | ||
if (resetTokenRecord) { | ||
_context10.next = 8; | ||
_context10.next = 9; | ||
break; | ||
@@ -831,7 +833,10 @@ } | ||
case 8: | ||
if ((0, _lodash.includes)(user.emails.map(function (email) { | ||
case 9: | ||
// TODO check time for expiry date | ||
emails = user.emails || []; | ||
if ((0, _lodash.includes)(emails.map(function (email) { | ||
return email.address; | ||
}), resetTokenRecord.email)) { | ||
_context10.next = 10; | ||
_context10.next = 12; | ||
break; | ||
@@ -842,11 +847,11 @@ } | ||
case 10: | ||
_context10.next = 12; | ||
case 12: | ||
_context10.next = 14; | ||
return this.db.setResetPasssword(user.id, resetTokenRecord.email, newPassword, token); | ||
case 12: | ||
case 14: | ||
// Changing the password should invalidate existing sessions | ||
this.db.invalidateAllSessions(user.id); | ||
case 13: | ||
case 15: | ||
case 'end': | ||
@@ -958,3 +963,3 @@ return _context10.stop(); | ||
var _ref14 = _asyncToGenerator(regeneratorRuntime.mark(function _callee13(userId, address) { | ||
var user, email, token, verifyEmailUrl; | ||
var user, email, emails, token, verifyEmailUrl; | ||
return regeneratorRuntime.wrap(function _callee13$(_context13) { | ||
@@ -987,7 +992,8 @@ while (1) { | ||
// Make sure the address is valid | ||
emails = user.emails || []; | ||
if (!(!address || !(0, _lodash.includes)(user.emails.map(function (email) { | ||
if (!(!address || !(0, _lodash.includes)(emails.map(function (email) { | ||
return email.address; | ||
}), address))) { | ||
_context13.next = 8; | ||
_context13.next = 9; | ||
break; | ||
@@ -998,10 +1004,10 @@ } | ||
case 8: | ||
case 9: | ||
token = (0, _tokens.generateRandomToken)(); | ||
_context13.next = 11; | ||
_context13.next = 12; | ||
return this.db.addEmailVerificationToken(userId, address, token); | ||
case 11: | ||
case 12: | ||
verifyEmailUrl = this._options.siteUrl + '/verify-email/' + token; | ||
_context13.next = 14; | ||
_context13.next = 15; | ||
return this.email.sendMail({ | ||
@@ -1014,3 +1020,3 @@ from: this.emailTemplates.verifyEmail.from ? this.emailTemplates.verifyEmail.from : this.emailTemplates.from, | ||
case 14: | ||
case 15: | ||
case 'end': | ||
@@ -1033,3 +1039,3 @@ return _context13.stop(); | ||
var _ref15 = _asyncToGenerator(regeneratorRuntime.mark(function _callee14(userId, address) { | ||
var user, token, resetPasswordUrl; | ||
var user, emails, token, resetPasswordUrl; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
@@ -1058,7 +1064,8 @@ while (1) { | ||
// Make sure the address is valid | ||
emails = user.emails || []; | ||
if (!(!address || !(0, _lodash.includes)(user.emails.map(function (email) { | ||
if (!(!address || !(0, _lodash.includes)(emails.map(function (email) { | ||
return email.address; | ||
}), address))) { | ||
_context14.next = 8; | ||
_context14.next = 9; | ||
break; | ||
@@ -1069,10 +1076,10 @@ } | ||
case 8: | ||
case 9: | ||
token = (0, _tokens.generateRandomToken)(); | ||
_context14.next = 11; | ||
_context14.next = 12; | ||
return this.db.addResetPasswordToken(userId, address, token); | ||
case 11: | ||
case 12: | ||
resetPasswordUrl = this._options.siteUrl + '/reset-password/' + token; | ||
_context14.next = 14; | ||
_context14.next = 15; | ||
return this.email.sendMail({ | ||
@@ -1085,3 +1092,3 @@ from: this.emailTemplates.resetPassword.from ? this.emailTemplates.resetPassword.from : this.emailTemplates.from, | ||
case 14: | ||
case 15: | ||
case 'end': | ||
@@ -1088,0 +1095,0 @@ return _context14.stop(); |
{ | ||
"name": "@accounts/server", | ||
"version": "0.0.4-alpha.6d363033", | ||
"version": "0.0.4-alpha.9b2e36fb", | ||
"description": "Fullstack authentication and accounts-management", | ||
@@ -12,2 +12,3 @@ "main": "lib/index.js", | ||
"compile": "babel ./src --out-dir ./lib", | ||
"postcompile": "npm run flow:prepublish", | ||
"prepublish": "npm run compile", | ||
@@ -17,2 +18,4 @@ "test": "npm run testonly", | ||
"testonly": "jest", | ||
"flow:check": "flow check", | ||
"flow:prepublish": "for i in `ls ./src/*.js`; do cp $i `echo $i | sed \"s/src/lib/g\" | sed \"s/js/js\\.flow/g\"`; done", | ||
"coverage": "npm run testonly -- --coverage", | ||
@@ -45,3 +48,3 @@ "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" | ||
"dependencies": { | ||
"@accounts/common": "^0.0.4-alpha.6d363033", | ||
"@accounts/common": "^0.0.4-alpha.9b2e36fb", | ||
"bcryptjs": "^2.4.0", | ||
@@ -48,0 +51,0 @@ "crypto": "^0.0.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323535
31
3950