From d49d2275d238cbf586bbc7112f793e7fe3fec36c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 10 Oct 2016 22:40:44 -0400 Subject: [PATCH] normalize email with lowercase --- src/Web/wwwroot/app/accounts/accountsRegisterController.js | 5 +++-- src/Web/wwwroot/app/services/authService.js | 1 + .../wwwroot/app/settings/settingsChangeEmailController.js | 7 ++++--- .../app/settings/settingsChangePasswordController.js | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Web/wwwroot/app/accounts/accountsRegisterController.js b/src/Web/wwwroot/app/accounts/accountsRegisterController.js index b4f37b0fc4..2e194b668b 100644 --- a/src/Web/wwwroot/app/accounts/accountsRegisterController.js +++ b/src/Web/wwwroot/app/accounts/accountsRegisterController.js @@ -26,10 +26,11 @@ angular return; } - var key = cryptoService.makeKey($scope.model.masterPassword, $scope.model.email); + var email = $scope.model.email.toLowerCase(); + var key = cryptoService.makeKey($scope.model.masterPassword, email); var request = { name: $scope.model.name, - email: $scope.model.email, + email: email, masterPasswordHash: cryptoService.hashPassword($scope.model.masterPassword, key), masterPasswordHint: $scope.model.masterPasswordHint }; diff --git a/src/Web/wwwroot/app/services/authService.js b/src/Web/wwwroot/app/services/authService.js index ac00c7d29e..43dbac874b 100644 --- a/src/Web/wwwroot/app/services/authService.js +++ b/src/Web/wwwroot/app/services/authService.js @@ -6,6 +6,7 @@ angular _userProfile = null; _service.logIn = function (email, masterPassword) { + email = email.toLowerCase(); var key = cryptoService.makeKey(masterPassword, email); var request = { diff --git a/src/Web/wwwroot/app/settings/settingsChangeEmailController.js b/src/Web/wwwroot/app/settings/settingsChangeEmailController.js index 1ce1bba59f..6867cd055f 100644 --- a/src/Web/wwwroot/app/settings/settingsChangeEmailController.js +++ b/src/Web/wwwroot/app/settings/settingsChangeEmailController.js @@ -9,14 +9,15 @@ $scope.token = function (model) { _masterPasswordHash = cryptoService.hashPassword(model.masterPassword); + var newEmail = model.newEmail.toLowerCase(); var request = { - newEmail: model.newEmail, + newEmail: newEmail, masterPasswordHash: _masterPasswordHash }; $scope.tokenPromise = apiService.accounts.emailToken(request, function () { - _newKey = cryptoService.makeKey(model.masterPassword, model.newEmail); + _newKey = cryptoService.makeKey(model.masterPassword, newEmail); _newMasterPasswordHash = cryptoService.hashPassword(model.masterPassword, _newKey); $scope.tokenSent = true; @@ -41,7 +42,7 @@ $q.all([sitesPromise, foldersPromise]).then(function () { var request = { token: model.token, - newEmail: model.newEmail, + newEmail: model.newEmail.toLowerCase(), masterPasswordHash: _masterPasswordHash, newMasterPasswordHash: _newMasterPasswordHash, ciphers: reencryptedSites.concat(reencryptedFolders) diff --git a/src/Web/wwwroot/app/settings/settingsChangePasswordController.js b/src/Web/wwwroot/app/settings/settingsChangePasswordController.js index 26d5834c81..67c1273930 100644 --- a/src/Web/wwwroot/app/settings/settingsChangePasswordController.js +++ b/src/Web/wwwroot/app/settings/settingsChangePasswordController.js @@ -25,7 +25,7 @@ $scope.processing = true; var profile = authService.getUserProfile(); - var newKey = cryptoService.makeKey(model.newMasterPassword, profile.email); + var newKey = cryptoService.makeKey(model.newMasterPassword, profile.email.toLowerCase()); var reencryptedSites = []; var sitesPromise = apiService.sites.list({ dirty: false }, function (encryptedSites) {