This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 568dce29ae463f486bfb439670b71d04e8ec751d Author: Yannick Martel <martel@©odelutin.com> Date: Tue Jan 20 17:52:34 2015 +0100 add second new password input to avoid bad write in password --- .../src/main/webapp/js/coselmar-controllers.js | 27 +++++++++++++++-- .../src/main/webapp/views/users/edituser.html | 35 ++++++++++++++++++---- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 5d40401..e1eadae 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -310,13 +310,14 @@ coselmarControllers.controller("NewUserCtrl", ['$scope', '$route', '$location', }; }]); -// Controller for single document View +// Controller for single User View & Edit coselmarControllers.controller("UserViewCtrl", ['$scope', '$route', '$location', 'userService', '$routeParams', function($scope, $route, $location, userService, $routeParams) { $scope.editMode = $routeParams.edit; if ($scope.editMode) { $scope.editPassword = true; + $scope.messages = []; } userService.getUser($routeParams.userId, $scope); @@ -362,8 +363,12 @@ coselmarControllers.controller("UserViewCtrl", if(isValidForm) { userService.saveUser($scope.user, function() { - // On success, back on users list - $location.path("/users"); + // On success, back on users list for admin or supervisor + if ($scope.currentUser.role == 'ADMIN' || $scope.currentUser.role == 'SUPERVISOR') { + $location.path("/users"); + } else { + $location.search(""); + } },function(error) { //TODO ymartel 20141118 : deal with error.status or statusText @@ -375,6 +380,22 @@ coselmarControllers.controller("UserViewCtrl", } ]); +// This directive checks two inputs have identical values. +// This is used for new password check +coselmarControllers.directive('identicalCheck', [function () { + return { + require: 'ngModel', + link: function (scope, elem, attrs, ctrl) { + var firstWord = '#' + attrs.identicalCheck; + elem.add(firstWord).on('keyup', function () { + scope.$apply(function () { + var areMatching = elem.val()===$(firstWord).val(); + ctrl.$setValidity('identicalmatch', areMatching); + }); + }); + } + } +}]); ///////////////////////////////////////////////// //////////// Questions Part /////////////////// diff --git a/coselmar-ui/src/main/webapp/views/users/edituser.html b/coselmar-ui/src/main/webapp/views/users/edituser.html index 0c9f91e..b58bb40 100644 --- a/coselmar-ui/src/main/webapp/views/users/edituser.html +++ b/coselmar-ui/src/main/webapp/views/users/edituser.html @@ -21,7 +21,13 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> - <div class="" ng-if="currentUser.role == 'ADMIN' || currentUser.role == 'SUPERVISOR'"> + <div class="" ng-if="currentUser.role == 'ADMIN' || currentUser.role == 'SUPERVISOR' || currentUser.userId == user.id"> + + <div ng-if="messages"> + <p ng-repeat="message in messages" class="block"> + {{message}} + </p> + </div> <form name="userForm" class="form-horizontal" role="form" ng-submit="saveUser(userForm.$valid)"> @@ -62,7 +68,7 @@ </div> - <div class="form-group" ng-if="currentUser.role == 'SUPERVISOR'"> + <div class="form-group" ng-if="currentUser.role == 'SUPERVISOR' && currentUser.id != user.userId"> <label class="col-md-4 control-label">Role *</label> <div class="col-md-5"> @@ -133,16 +139,35 @@ </div> - <div class="form-group" ng-if="editPassword"> + <div class="form-group" ng-if="editPassword" + ng-class="{'has-error' : (userForm.newPassword.$invalid + && !userForm.newPassword.$pristine ) + || userForm.confirmNewPassword.$error.identicalmatch }"> + <label class="col-md-4 control-label">New Password</label> <div class="col-md-5"> <input type="password" class="form-control" name="newPassword" - ng-model="user.newPassword" ng-minlength="6" placeholder="new password"/> + id="newPassword" placeholder="new password" + ng-model="user.newPassword" ng-minlength="6" /> + + <input type="password" class="form-control" name="confirmNewPassword" + id="confirmPassword" placeholder="confirm password" + ng-model="confirmNewPassword" ng-minlength="6" + identical-check="newPassword" + ng-class="{'has-error' : userForm.confirmNewPassword.$error.identicalmatch }"/> + + <p ng-show="userForm.newPassword.$invalid && !userForm.newPassword.$pristine" class="help-block"> + New password should contain at least 6 characters. + {{userForm.newPassword.$error}} + </p> + <p ng-show="userForm.confirmNewPassword.$error.identicalmatch" class="help-block"> + The two new passwords don't match. + </p> </div> - </div> + <div class="form-group" ng-if="userForm.$valid || currentUser.role == 'ADMIN'"> <div class="float-right col-md-4"> <input type="submit" value="Validate" class="btn btn-primary"/> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.