diff --git a/src/translation/en.json b/src/translation/en.json
index 5915a99f0..ff3b2e4f3 100644
--- a/src/translation/en.json
+++ b/src/translation/en.json
@@ -364,7 +364,11 @@
"changeFallbackEmail": {
"title": "Change password recovery email address",
"errorEmailRequired": "A valid email address is required",
- "errorEmailInvalid": "The Email address is not valid"
+ "errorEmailInvalid": "The Email address is not valid",
+ "email": "New password recovery email address",
+ "password": "Password for confirmation",
+ "errorWrongPassword": "Wrong password",
+ "errorPasswordRequired": "A password is required"
},
"changeDisplayName": {
"title": "Change your display name",
diff --git a/src/views/profile.html b/src/views/profile.html
index 62a5b01ac..74aab7f09 100644
--- a/src/views/profile.html
+++ b/src/views/profile.html
@@ -122,14 +122,24 @@
diff --git a/src/views/profile.js b/src/views/profile.js
index 7a131759a..85a426779 100644
--- a/src/views/profile.js
+++ b/src/views/profile.js
@@ -337,13 +337,19 @@ angular.module('Application').controller('ProfileController', ['$scope', '$trans
$scope.fallbackEmailChange = {
busy: false,
- error: {},
+ error: {
+ email: false,
+ password: false
+ },
email: '',
+ password: '',
reset: function () {
$scope.fallbackEmailChange.busy = false;
$scope.fallbackEmailChange.error.email = null;
+ $scope.fallbackEmailChange.error.password = null;
$scope.fallbackEmailChange.email = '';
+ $scope.fallbackEmailChange.password = '';
$scope.fallbackEmailChangeForm.$setUntouched();
$scope.fallbackEmailChangeForm.$setPristine();
@@ -356,16 +362,28 @@ angular.module('Application').controller('ProfileController', ['$scope', '$trans
submit: function () {
$scope.fallbackEmailChange.error.email = null;
+ $scope.fallbackEmailChange.error.password = null;
$scope.fallbackEmailChange.busy = true;
var data = {
- fallbackEmail: $scope.fallbackEmailChange.email
+ fallbackEmail: $scope.fallbackEmailChange.email,
+ password: $scope.fallbackEmailChange.password
};
Client.updateProfile(data, function (error) {
$scope.fallbackEmailChange.busy = false;
- if (error) return console.error('Unable to change fallback email.', error);
+ if (error) {
+ if (error.statusCode === 412) {
+ $scope.fallbackEmailChange.error.password = true;
+ $scope.fallbackEmailChange.password = '';
+ $scope.fallbackEmailChangeForm.password.$setPristine();
+ $('#inputFallbackEmailChangePassword').focus();
+ } else {
+ console.error('Unable to change fallback email.', error);
+ }
+ return;
+ }
// update user info in the background
Client.refreshUserInfo();