diff --git a/services/web/app/src/Features/User/UserRegistrationHandler.js b/services/web/app/src/Features/User/UserRegistrationHandler.js index 809adb2db7..09f98bc9b7 100644 --- a/services/web/app/src/Features/User/UserRegistrationHandler.js +++ b/services/web/app/src/Features/User/UserRegistrationHandler.js @@ -122,7 +122,7 @@ const UserRegistrationHandler = { const ONE_WEEK = 7 * 24 * 60 * 60 // seconds OneTimeTokenHandler.getNewToken( 'password', - { user_id: user._id.toString(), email }, + { user_id: user._id.toString(), email: user.email }, { expiresIn: ONE_WEEK }, (err, token) => { if (err != null) { diff --git a/services/web/test/unit/src/User/UserRegistrationHandlerTests.js b/services/web/test/unit/src/User/UserRegistrationHandlerTests.js index ec220f3a8f..541fca5034 100644 --- a/services/web/test/unit/src/User/UserRegistrationHandlerTests.js +++ b/services/web/test/unit/src/User/UserRegistrationHandlerTests.js @@ -250,7 +250,7 @@ describe('UserRegistrationHandler', function() { describe('registerNewUserAndSendActivationEmail', function() { beforeEach(function() { - this.email = 'email@example.com' + this.email = 'Email@example.com' this.crypto.randomBytes = sinon.stub().returns({ toString: () => { return (this.password = 'mock-password') @@ -266,6 +266,7 @@ describe('UserRegistrationHandler', function() { describe('with a new user', function() { beforeEach(function() { + this.user.email = this.email.toLowerCase() this.handler.registerNewUser.callsArgWith(1, null, this.user) return this.handler.registerNewUserAndSendActivationEmail( this.email, @@ -283,7 +284,10 @@ describe('UserRegistrationHandler', function() { }) it('should generate a new password reset token', function() { - const data = { user_id: this.user._id.toString(), email: this.email } + const data = { + user_id: this.user._id.toString(), + email: this.user.email + } return this.OneTimeTokenHandler.getNewToken .calledWith('password', data, { expiresIn: 7 * 24 * 60 * 60 }) .should.equal(true)