[pollen] branch feature/adminUser updated (b34d2c1 -> f4e8036)
This is an automated email from the git hooks/post-receive script. New change to branch feature/adminUser in repository pollen. See http://git.chorem.org/pollen.git from b34d2c1 add method to anonymize User new 685819f add method for ban user new f4e8036 add good error when you want to change password The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit f4e8036d2ab21ead54de567f40b566a2a2128f82 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 23 12:27:35 2014 +0200 add good error when you want to change password commit 685819f509a94927c27163d7031b6cdddfb8f02e Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 23 10:32:28 2014 +0200 add method for ban user Summary of changes: .../chorem/pollen/rest/api/v1/PollenUserApi.java | 11 ++++-- pollen-rest-api/src/main/resources/mapping | 1 + .../pollen/services/service/PollenUserService.java | 42 ++++++++++++++++++---- .../src/main/webapp/js/controllers/userCtrl.js | 15 ++++++-- pollen-ui-angular/src/main/webapp/js/services.js | 4 +++ .../src/main/webapp/partials/user-admin-list.html | 1 + .../src/main/webapp/partials/user-edit.html | 12 +++---- 7 files changed, 68 insertions(+), 18 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/adminUser in repository pollen. See http://git.chorem.org/pollen.git commit 685819f509a94927c27163d7031b6cdddfb8f02e Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 23 10:32:28 2014 +0200 add method for ban user --- .../chorem/pollen/rest/api/v1/PollenUserApi.java | 9 ++++++-- pollen-rest-api/src/main/resources/mapping | 1 + .../pollen/services/service/PollenUserService.java | 24 +++++++++++++++++++--- .../src/main/webapp/js/controllers/userCtrl.js | 13 +++++++++--- pollen-ui-angular/src/main/webapp/js/services.js | 4 ++++ .../src/main/webapp/partials/user-admin-list.html | 1 + 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java index dfbf98b..b02027a 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java @@ -79,12 +79,17 @@ public class PollenUserApi extends WebMotionController { return pollenUserService.adminUser(user); } - public void deleteUser(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId) throws InvalidFormException { + public void deleteUser(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId, boolean anonymize) throws InvalidFormException { - pollenUserService.deleteUser(userId.getEntityId()); + pollenUserService.deleteUser(userId.getEntityId(), anonymize); } + public void banUser(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId, boolean anonymize) { + + pollenUserService.banUser(userId.getEntityId(), anonymize); + } + public void validateUserEmail(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId, String token) throws PollenInvalidEmailActivationTokenException { diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index f3d8522..ddc03f7 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -132,6 +132,7 @@ PUT,POST /v1/users/{userId} PollenUserApi.editUser PUT,POST /v1/users/{userId}/password PollenUserApi.changePassword POST /v1/users/{userId}/admin PollenUserApi.adminUser DELETE /v1/users/{userId} PollenUserApi.deleteUser +DELETE /v1/users/{userId}/ban PollenUserApi.banUser PUT /v1/users/{userId}?token={} PollenUserApi.validateUserEmail # VoteCountingApi diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index a15f3d1..d577551 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -131,15 +131,17 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer return toBean(PollenUserBean.class, userSaved, pollenUserFunction); } - public void deleteUser(String userId) { + public void deleteUser(String userId, boolean anonymize) { checkNotNull(userId); checkIsAdmin(); PollenUser user = getUser0(userId); - anonymizeUser(user); - + if (anonymize) { + anonymizeUser(user); + } + getPollenUserDao().delete(user); commit(); @@ -147,6 +149,22 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer } + public void banUser(String userId, boolean anonymize) { + + checkNotNull(userId); + + PollenUser user = getUser0(userId); + + if (anonymize) { + anonymizeUser(user); + } + + user.setPassword(""); + commit(); + + getNotificationService().onUserEdited(user); + } + public void changePassword(String userId, String oldPassword, String newPassword) throws PollenInvalidPasswordException { 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 f060a02..b2c3add 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -116,8 +116,8 @@ angular.module('userControllers', []) } }]) -.controller('UserListCtrl', ['$scope', '$routeParams', 'User', 'Page', - function ($scope, $routeParams, User, Page) { +.controller('UserListCtrl', ['$scope', '$rootScope', '$routeParams', 'User', 'Page', + function ($scope, $rootScope, $routeParams, User, Page) { Page.setTitle('title.user.list'); @@ -152,13 +152,20 @@ angular.module('userControllers', []) }; $scope.deleteUser = function (user) { - User.remove({userId:user.id}, function (data) { + User.remove({userId:user.id, anonymize:true}, function (data) { + $rootScope.$broadcast('newSuccess', 'user.delete.success'); var userIndex = $scope.data.users.indexOf(user); if (userIndex >= 0) { $scope.data.users.splice(userIndex, 1); } }); }; + + $scope.banUser = function (user) { + User.ban({userId : user.id, anonymize:true}, function (data) { + $rootScope.$broadcast('newSuccess', 'user.ban.success'); + }); + }; }]) .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 82ef663..4c2557e 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -230,6 +230,10 @@ angular.module('pollenServices', ['ngResource']) return 'oldPassword='+encodeURIComponent(data.password)+ '&newPassword='+encodeURIComponent(data.newPassword); } + }, + 'ban' : { + method:'DELETE', + url: conf.restURL+'/users/:userId/ban' } } ); diff --git a/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html b/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html index 6b3cd54..a7c09f3 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html @@ -34,6 +34,7 @@ </td> <td class="action"> <button class="btn btn-primary" ng-click="saveUser(user)"> <span class="glyphicon glyphicon-save"></span> </button> + <button class="btn btn-warning" ng-click="banUser(user)"> <span class="glyphicon glyphicon-ban-circle"></span> </button> <button class="btn btn-danger" ng-click="deleteUser(user)"> <span class="glyphicon glyphicon-trash"></span> </button> </td> </tr> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/adminUser in repository pollen. See http://git.chorem.org/pollen.git commit f4e8036d2ab21ead54de567f40b566a2a2128f82 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 23 12:27:35 2014 +0200 add good error when you want to change password --- .../org/chorem/pollen/rest/api/v1/PollenUserApi.java | 2 +- .../pollen/services/service/PollenUserService.java | 18 +++++++++++++++--- .../src/main/webapp/js/controllers/userCtrl.js | 2 ++ .../src/main/webapp/partials/user-edit.html | 12 ++++++------ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java index b02027a..55893b8 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java @@ -101,7 +101,7 @@ public class PollenUserApi extends WebMotionController { public void changePassword(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId, String oldPassword, - String newPassword) throws PollenInvalidPasswordException { + String newPassword) throws InvalidFormException { pollenUserService.changePassword(userId.getEntityId(), oldPassword, newPassword); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index d577551..f49f1c9 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -167,7 +167,7 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer public void changePassword(String userId, String oldPassword, - String newPassword) throws PollenInvalidPasswordException { + String newPassword) throws InvalidFormException { checkNotNull(userId); checkNotNull(oldPassword); @@ -175,8 +175,20 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer PollenUser user = getUser0(userId); - // check old password - getSecurityService().checkUserPassword(user, oldPassword); + ErrorMap errorMap = new ErrorMap(); + + boolean passwordNotBlank = checkNotBlank(errorMap, "newPassword", newPassword, l(getLocale(), "pollen.error.user.passwordEmpty")); + + if (passwordNotBlank) { + // check old password + try { + getSecurityService().checkUserPassword(user, oldPassword); + } catch (PollenInvalidPasswordException e) { + check(errorMap, "password", false, l(getLocale(), "pollen.error.user.passwordInvalid")); + } + } + + errorMap.failIfNotEmpty(); // set new password getSecurityService().setUserPassword(user, newPassword); 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 b2c3add..68f8e03 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -94,6 +94,8 @@ angular.module('userControllers', []) } $scope.data.user.password = ''; + $scope.data.user.newPassword = ''; + $scope.data.user.newPassword2 = ''; $scope.editUser = function () { User.update($scope.data.user, function (data) { 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 1d75891..15fdd66 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-edit.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-edit.html @@ -20,8 +20,8 @@ --> <h2> {{ 'title.user.edit' | translate }} </h2> -<form class="horizontal-form" ng-submit="editUser()"> - <div class="control-group"> +<form class="horizontal-form"> + <div class="control-group row"> <label for="formName" class="col-sm-5 text-right control-label"> {{ 'user.name' | translate }} </label> @@ -32,7 +32,7 @@ </div> </div> - <div class="control-group"> + <div class="control-group row"> <label for="formEmail" class="col-sm-5 text-right control-label"> {{ 'user.mail' | translate }} @@ -46,7 +46,7 @@ </div> </div> - <div class="control-group"> + <div class="control-group row"> <label for="formPassword" class="col-sm-5 text-right control-label"> {{ 'user.passwordCurrent' | translate }} </label> @@ -67,13 +67,13 @@ <div class="col-sm-1"></div> </div> -<form class="horizontal-form" ng-submit="editPassword()"> +<form class="horizontal-form"> <div class="control-group"> <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="data.user.password" /> + <input type="password" id="formCurrentPassword" class="form-control" ng-model="data.user.password" auto-save="editPassword()" /> </div> <div class="col-sm-1"> <info-error error="restError.password[0]" data="data.user.password"></info-error> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm