diff --git a/bootstrap-ui/src/main/webapp/app/controllers.js b/bootstrap-ui/src/main/webapp/app/controllers.js index 5a04e54ec..479616805 100644 --- a/bootstrap-ui/src/main/webapp/app/controllers.js +++ b/bootstrap-ui/src/main/webapp/app/controllers.js @@ -305,6 +305,9 @@ controllers.controller("ProfileController", function ProfileController($scope, U $scope.newPasswordRepeated = undefined; $scope.changePassword = function () { + $scope.passwordChangeForm.currentPassword.$dirty = true; + $scope.passwordChangeForm.newPassword.$dirty = true; + $scope.passwordChangeForm.newPasswordRepeated.$dirty = true; if ($scope.passwordChangeForm.$valid) { ProfileService.changePassword($scope.currentPassword, $scope.newPassword, function () { showInfoMessage("Password changed!"); diff --git a/bootstrap-ui/src/main/webapp/app/directives.js b/bootstrap-ui/src/main/webapp/app/directives.js index 2496127ce..ae4a5559c 100644 --- a/bootstrap-ui/src/main/webapp/app/directives.js +++ b/bootstrap-ui/src/main/webapp/app/directives.js @@ -10,18 +10,23 @@ directives.directive("bsBlur", function() { } }); -directives.directive("stringMatches", function() { +directives.directive("repeatPassword", function() { return { require: "ngModel", link: function(scope, elem, attrs, ctrl) { - ctrl.$parsers.unshift(function(viewValue) { - if(viewValue === scope[attrs.stringMatches]) { - ctrl.$setValidity("match", true); - return viewValue; - } else { - ctrl.$setValidity("match", false); - return undefined; + var otherInput = elem.inheritedData("$formController")[attrs.repeatPassword]; + + ctrl.$parsers.push(function(value) { + if(value === otherInput.$viewValue) { + ctrl.$setValidity("repeat", true); + return value; } + ctrl.$setValidity("repeat", false); + }); + + otherInput.$parsers.push(function(value) { + ctrl.$setValidity("repeat", value === ctrl.$viewValue); + return value; }); } }; diff --git a/bootstrap-ui/src/main/webapp/partials/secured/profile.html b/bootstrap-ui/src/main/webapp/partials/secured/profile.html index b139414f7..2d61e5a69 100644 --- a/bootstrap-ui/src/main/webapp/partials/secured/profile.html +++ b/bootstrap-ui/src/main/webapp/partials/secured/profile.html @@ -32,7 +32,7 @@
-
+
Password
@@ -62,11 +62,11 @@
+ ng-model="newPasswordRepeated" repeat-password="newPassword" required> Repeat password Passwords don't match + ng-show="passwordChangeForm.newPasswordRepeated.$dirty && passwordChangeForm.newPasswordRepeated.$error.repeat">Passwords don't match