This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit d37923e815a35900fa7c3f63d24ce503b63db0c5 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jun 11 11:47:42 2014 +0200 edit user password, change Auto-save, --- pollen-rest-api/src/main/resources/mapping | 2 + pollen-ui-angular/src/main/webapp/css/style.css | 4 ++ pollen-ui-angular/src/main/webapp/i18n/en.js | 2 + pollen-ui-angular/src/main/webapp/i18n/fr.js | 2 + pollen-ui-angular/src/main/webapp/js/app.js | 12 ++--- .../src/main/webapp/js/controllers/pollCtrl.js | 26 +++++----- .../src/main/webapp/js/controllers/userCtrl.js | 11 ++++ pollen-ui-angular/src/main/webapp/js/services.js | 8 +++ .../main/webapp/partials/poll-listParticipant.html | 6 +-- .../src/main/webapp/partials/poll.html | 10 ++-- .../src/main/webapp/partials/user-edit.html | 58 ++++++++++++++++++---- 11 files changed, 104 insertions(+), 37 deletions(-) diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index 7276722..661740f 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -40,6 +40,7 @@ org.chorem.pollen.services.service.security.PollenInvalidSessionTokenException org.chorem.pollen.services.service.security.PollenUnauthorizedException ErrorAction.on403 org.chorem.pollen.services.service.security.PollenInvalidPermissionException ErrorAction.on403 org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException ErrorAction.on403 +org.chorem.pollen.services.service.security.PollenInvalidPasswordException ErrorAction.on400Form org.chorem.pollen.services.service.InvalidFormException ErrorAction.on400Form org.nuiton.topia.persistence.TopiaNoResultException ErrorAction.on404 org.chorem.pollen.services.service.InvalidEntityLinkException ErrorAction.on404 @@ -119,6 +120,7 @@ GET /v1/users PollenUserApi.getUsers GET /v1/users/{userId} PollenUserApi.getUser POST /v1/users PollenUserApi.createUser PUT,POST /v1/users/{userId} PollenUserApi.editUser +PUT,POST /v1/users/{userId}/password PollenUserApi.changePassword DELETE /v1/users/{userId} PollenUserApi.deleteUser PUT /v1/users/{userId}?token={} PollenUserApi.validateUserEmail diff --git a/pollen-ui-angular/src/main/webapp/css/style.css b/pollen-ui-angular/src/main/webapp/css/style.css index 36a52f2..144f707 100644 --- a/pollen-ui-angular/src/main/webapp/css/style.css +++ b/pollen-ui-angular/src/main/webapp/css/style.css @@ -251,4 +251,8 @@ i.icon-collapse { input[type=number] { width:80px; +} + +hr { + border-top:1px solid #CCCCCC; } \ No newline at end of file diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index 17ac768..00ee69b 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -21,6 +21,8 @@ var translateEN = { 'user.mail' : 'e-mail', 'user.password' : 'Password', 'user.password2' : 'Confirm', +'user.passwordNew' : 'New password', +'user.passwordCurrent' : 'Current password', 'user.rememberMe' : 'Remember Me', 'user.forgotPassword' : 'Forgot Password', 'user.register.success' : 'Register with success', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index 4978334..78f9297 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -21,6 +21,8 @@ var translateFR = { 'user.mail' : 'Courriel', 'user.password' : 'Mot de passe', 'user.password2' : 'Confirmation', +'user.passwordNew' : 'Nouveau Mot de passe', +'user.passwordCurrent' : 'Mot de passe Actuel', 'user.rememberMe' : 'Connexion automatique', 'user.forgotPassword' : 'Mot de passe oublié', 'user.register.success' : 'Compte enregisté, un mail de validation vient d\'être envoyé..', diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index 11774ca..102da70 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -204,13 +204,11 @@ angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'userC restrict : 'A', link : function (scope, element, attrs) { element.bind('change', function () { - if (scope.globalVariables.edit) { - scope.$apply(function () { - $timeout(function() { - scope.$eval(attrs.autoSave); - },100); - }); - } + scope.$apply(function () { + $timeout(function() { + scope.$eval(attrs.autoSave); + }, 100); + }); }); } } diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index 8ce5be8..72bc2ae 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -24,8 +24,8 @@ angular.module('pollControllers', []) }]) .controller('PollCtrl', - ['$scope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', - function ( $scope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate) { + ['$scope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', + function ( $scope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route) { $scope.setTab = function (defaultValue) { if (angular.isDefined($routeParams.tab)) { return $routeParams.tab; @@ -145,10 +145,16 @@ angular.module('pollControllers', []) } initTemplateURL(); -}]) + var lastRoute = $route.current; + $scope.$on('$locationChangeSuccess', function(event) { + if (lastRoute.$$route.controller == $route.current.$$route.controller) { + $route.current = lastRoute; + } + }); +}]) -.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$timeout', '$routeParams', '$route', function ($scope, $controller, $modal, $timeout, $routeParams, $route) { +.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$timeout', '$routeParams', function ($scope, $controller, $modal, $timeout, $routeParams) { $controller('PollCtrl', {$scope:$scope}); $scope.tab = $scope.setTab('edit'); @@ -159,14 +165,6 @@ angular.module('pollControllers', []) $scope.globalVariables.lastDate = new Date(); $scope.restError = {}; - - var lastRoute = $route.current; - $scope.$on('$locationChangeSuccess', function(event) { - if (lastRoute.$$route.controller == $route.current.$$route.controller) { - $route.current = lastRoute; - } - }); - //////////////////////////////// //// VOTER LIST ///// //////////////////////////////// @@ -575,6 +573,10 @@ angular.module('pollControllers', []) } initPoll(); + $scope.autoSavePoll = function () { + $scope.savePoll(); + }; + $scope.savePoll = function () { $scope.data.poll.$update({permission:$scope.globalVariables.permission}, function (data) { $scope.globalVariables.saved = true; diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js index d9afb8b..8a3c40d 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -73,6 +73,17 @@ $scope.restError = error.data; }); } + + $scope.editPassword = function () { + if ($scope.currentUser.newPassword == $scope.currentUser.newPassword2) { + User.editPassword($scope.currentUser, function (data) { + SessionStorage.save({user:data}); + $scope.saved = true; + }, function (error) { + $scope.restError = error.data; + }); + } + } }]) .controller('UserLoginCtrl', ['$scope', 'UserLogin', 'UserLogout', 'User', 'SessionStorage', '$route', '$location', '$translate', function ($scope, UserLogin, UserLogout, User, SessionStorage, $route, $location, $translate) { diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index 1252fad..3a82d25 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -179,6 +179,14 @@ angular.module('pollenServices', ['ngResource']) transformRequest : function (data, headersGetter) { return transformParam(data); } + }, + 'editPassword' : { + method:'POST', + url: conf.restURL+'/users/:userId/password', + transformRequest : function (data, headersGetter) { + return 'oldPassword='+encodeURIComponent(data.password)+ + '&newPassword='+encodeURIComponent(data.newPassword); + } } } ); diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html index b0ae0db..3a6cdf9 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html @@ -21,15 +21,15 @@ <h2>{{ 'poll.restricted.pollType' | translate }}</h2> <div> <label for="formFree"> - <input type="radio" ng-model="data.poll.pollType" name="type" value="FREE" id="formFree" auto-save="savePoll()"/> + <input type="radio" ng-model="data.poll.pollType" name="type" value="FREE" id="formFree" auto-save="autoSavePoll()"/> {{ 'poll.restricted.free' | translate }} </label> <label for="formRestricted"> - <input type="radio" ng-model="data.poll.pollType" name="type" value="RESTRICTED" id="formRestricted" auto-save="savePoll()"/> + <input type="radio" ng-model="data.poll.pollType" name="type" value="RESTRICTED" id="formRestricted" auto-save="autoSavePoll()"/> {{ 'poll.restricted.restricted' | translate }} </label> <label for="formGroup"> - <input type="radio" ng-model="data.poll.pollType" name="type" value="GROUP" id="formGroup" auto-save="savePoll()"/> + <input type="radio" ng-model="data.poll.pollType" name="type" value="GROUP" id="formGroup" auto-save="autoSavePoll()"/> {{ 'poll.restricted.group' | translate }} </label> diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index 047c09b..4f4517c 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -25,10 +25,10 @@ <alert type="success" class="alert-float" ng-if="globalVariables.commentMode && globalVariables.saved" close="globalVariables.saved = false">{{ 'comment.added' | translate }}</alert> <ul class="nav nav-tabs"> - <li ng-class="{active: tab == 'home'}"><a href="{{urlTab}}tab=home"> <span class="glyphicon glyphicon-home"></span> </a></li> - <li ng-class="{active: tab == 'vote'}" ng-show="data.poll.id"><a href="{{globalVariables.linkVote}}">{{ 'poll.tab.vote' | translate }}</a></li> - <li ng-class="{active: tab == 'comment'}" ng-show="data.poll.id"><a href="{{globalVariables.linkComment}}">{{ 'poll.tab.comment' | translate }}</a></li> - <li ng-class="{active: tab == 'result'}" ng-show="!globalVariables.create"><a href="{{globalVariables.linkResult}}">{{ 'poll.tab.result' | translate }}</a></li> + <li ng-class="{active: tab == 'home'}"><a href="{{urlTab}}tab=home" ng-click="tab = 'home'"> <span class="glyphicon glyphicon-home"></span> </a></li> + <li ng-class="{active: tab == 'vote'}" ng-show="data.poll.id"><a href="{{globalVariables.linkVote}}" ng-click="tab = 'vote'">{{ 'poll.tab.vote' | translate }}</a></li> + <li ng-class="{active: tab == 'comment'}" ng-show="data.poll.id"><a href="{{globalVariables.linkComment}}" ng-click="tab = 'comment'">{{ 'poll.tab.comment' | translate }}</a></li> + <li ng-class="{active: tab == 'result'}" ng-show="!globalVariables.create"><a href="{{globalVariables.linkResult}}" ng-click="tab = 'result'">{{ 'poll.tab.result' | translate }}</a></li> <li ng-class="{active: tab == 'edit'}" ng-show="globalVariables.create"><a href="#/poll/create" ng-click="tab = 'edit'">{{ 'poll.tab.create' | translate }}</a></li> <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}" ng-click="tab = 'edit'">{{ 'poll.tab.edit' | translate }}</a></li> <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{globalVariables.linkConf || '#/poll/create?tab=conf'}}" ng-click="tab = 'conf'">{{ 'poll.tab.conf' | translate }}</a></li> @@ -45,7 +45,7 @@ </h1> <h1 ng-show="showEditTitle"> - <input type="text" class="form-control" focus-me="showEditTitle" ng-model="data.poll.title" ng-exit="showEditTitle = false" auto-save="savePoll()" required/> + <input type="text" class="form-control" focus-me="showEditTitle" ng-model="data.poll.title" ng-exit="showEditTitle = false" auto-save="autoSavePoll()" required/> </h1> </div> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-edit.html b/pollen-ui-angular/src/main/webapp/partials/user-edit.html index a0d1b68..ccb0ae2 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-edit.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-edit.html @@ -28,7 +28,7 @@ {{ 'user.name' | translate }} </label> <div class="col-sm-6"> - <input type="text" id="formName" class="form-control" ng-model="currentUser.name"/> + <input type="text" id="formName" class="form-control" ng-model="currentUser.name" auto-save="editUser()" /> </div> <div class="col-sm-1"> </div> @@ -41,7 +41,7 @@ </label> <div class="col-sm-6"> - <input type="email" id="formEmail" name="email" class="form-control" ng-model="currentUser.email"/> + <input type="email" id="formEmail" name="email" class="form-control" ng-model="currentUser.email" auto-save="editUser()" /> </div> <div class="col-sm-1"> <info-error error="restError.email[0]" data="currentUser.email"></info-error> @@ -50,21 +50,59 @@ <div class="control-group"> <label for="formPassword" class="col-sm-5 text-right control-label"> - {{ 'user.password' | translate }} + {{ 'user.passwordCurrent' | translate }} </label> <div class="col-sm-6"> - <input type="password" id="formPassword" class="form-control" ng-model="currentUser.password"/> + <input type="password" id="formPassword" class="form-control" ng-model="currentUser.password" auto-save="editUser()" /> </div> <div class="col-sm-1"> <info-error error="restError.password[0]" data="currentUser.password"></info-error> </div> </div> +</form> + + +<div> + <div class="col-sm-2"></div> + <div class="col-sm-9"><hr/></div> + <div class="col-sm-1"></div> +</div> + +<form class="horizontal-form" ng-submit="editPassword()"> <div class="control-group"> - <div class="col-sm-5"></div> - <div class="col-sm-6"> - <button class="btn btn-primary" type="submit">{{ 'action.send' | translate }} </button> - </div> - <div class="col-sm-1"></div> + <label for="formCurrentPassword" class="col-sm-5 text-right control-label"> + {{ 'user.passwordCurrent' | translate }} + </label> + <div class="col-sm-6"> + <input type="password" id="formCurrentPassword" class="form-control" ng-model="currentUser.password" /> + </div> + <div class="col-sm-1"> + <info-error error="restError.password[0]" data="currentUser.password"></info-error> + </div> + </div> + + <div class="control-group"> + <label for="formNewPassword" class="col-sm-5 text-right control-label"> + {{ 'user.passwordNew' | translate }} + </label> + <div class="col-sm-6"> + <input type="password" id="formNewPassword" class="form-control" ng-model="currentUser.newPassword" auto-save="editPassword()"/> + </div> + <div class="col-sm-1"> + <info-error error="restError.newPassword[0]" data="currentUser.newPassword"></info-error> + </div> + </div> + + <div class="control-group"> + <label for="formNewPassword2" class="col-sm-5 text-right control-label"> + {{ 'user.password2' | translate }} + </label> + <div class="col-sm-6"> + <input type="password" id="formNewPassword2" class="form-control" ng-model="currentUser.newPassword2" auto-save="editPassword()"/> + </div> + <div class="col-sm-1"> + <span class="glyphicon glyphicon-exclamation-sign danger" tooltip="{{ 'user.error.password.diff' | translate }}" ng-if="currentUser.newPassword != currentUser.newPassword2"></span> + </div> </div> -</form> \ No newline at end of file +</form> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.