This is an automated email from the git hooks/post-receive script. New commit to branch feature/44_several_email_address in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 86a73fba8d010b59ec2d29ed3f2fa3307bf8f20b Author: Kevin Morin <morin@codelutin.com> Date: Mon Oct 16 11:01:25 2017 +0200 refs #44 validation de l'adresse email par l'admin --- .../chorem/pollen/rest/api/v1/PollenUserApi.java | 43 ++++++++++++++++++++++ .../pollen/services/service/PollenUserService.java | 30 +++++++++++++++ 2 files changed, 73 insertions(+) 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 7abdf256..e8681e10 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 @@ -142,6 +142,16 @@ public class PollenUserApi { pollenUserService.validateUserEmail(userId.getEntityId(), token); } + @Path("/users/{userId}/email/{emailAddressId}") + @PUT + public void validateUserEmail(@Context PollenUserService pollenUserService, + @PathParam("userId") PollenEntityId<PollenUser> userId, + @PathParam("emailAddressId") PollenEntityId<PollenUserEmailAddress> emailAddressId) + throws PollenInvalidEmailActivationTokenException { + + pollenUserService.validateUserEmailByAdmin(userId.getEntityId(), emailAddressId.getEntityId()); + } + @Path("/user/password") @PUT @POST public void changePassword(@Context PollenUserService pollenUserService, @@ -215,6 +225,13 @@ public class PollenUserApi { pollenUserService.deleteAvatar(); } + @Path("/users/{userId}/avatar") + @DELETE + public void deleteUserAvatar(@Context PollenUserService pollenUserService, + @PathParam("userId") PollenEntityId<PollenUser> userId) { + pollenUserService.deleteAvatar(userId.getEntityId()); + } + @Path("/user/email") @POST public PollenEntityRef<PollenUserEmailAddress> addEmailAddress(@Context PollenUserService pollenUserService, @@ -222,6 +239,14 @@ public class PollenUserApi { return pollenUserService.addEmailAddress(emailAddress); } + @Path("/users/{userId}/email") + @POST + public PollenEntityRef<PollenUserEmailAddress> addEmailAddress(@Context PollenUserService pollenUserService, + @PathParam("userId") PollenEntityId<PollenUser> userId, + String emailAddress) throws InvalidFormException { + return pollenUserService.addEmailAddress(userId.getEntityId(), emailAddress); + } + @Path("/user/email/default") @PUT public void setDefaultEmailAddress(@Context PollenUserService pollenUserService, @@ -230,6 +255,15 @@ public class PollenUserApi { pollenUserService.setDefaultEmailAddress(emailAddressId.getEntityId()); } + @Path("/users/{userId}/email/default") + @PUT + public void setDefaultEmailAddress(@Context PollenUserService pollenUserService, + @PathParam("userId") PollenEntityId<PollenUser> userId, + @QueryParam("emailAddressId") PollenEntityId<PollenUserEmailAddress> emailAddressId) + throws PollenEmailNotValidatedException { + pollenUserService.setDefaultEmailAddress(userId.getEntityId(), emailAddressId.getEntityId()); + } + @Path("/user/email/{emailAddressId}") @DELETE public void removeEmailAddress(@Context PollenUserService pollenUserService, @@ -237,4 +271,13 @@ public class PollenUserApi { throws PollenDefaultEmailAddressException { pollenUserService.removeEmailAddress(emailAddressId.getEntityId()); } + + @Path("/users/{userId}/email/{emailAddressId}") + @DELETE + public void removeEmailAddress(@Context PollenUserService pollenUserService, + @PathParam("userId") PollenEntityId<PollenUser> userId, + @PathParam("emailAddressId") PollenEntityId<PollenUserEmailAddress> emailAddressId) + throws PollenDefaultEmailAddressException { + pollenUserService.removeEmailAddress(userId.getEntityId(), emailAddressId.getEntityId()); + } } 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 3b772a5e..944a14af 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 @@ -255,6 +255,27 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer } + public void validateUserEmailByAdmin(String userId, String emailAddressId) throws PollenInvalidEmailActivationTokenException { + + checkIsAdmin(); + checkNotNull(userId); + checkNotNull(emailAddressId); + + PollenUser user = getUser0(userId); + PollenUserEmailAddress emailAddress = getPollenUserEmailAddressDao().forTopiaIdEquals(emailAddressId).findUnique(); + if (emailAddress == null || !user.containsEmailAddresses(emailAddress)) { + throw new PollenInvalidEmailActivationTokenException(); + } + + // reset token in database + emailAddress.setActivationToken(null); + + commit(); + + getNotificationService().onUserEmailValidated(user, emailAddress); + + } + public void resendValidation(String email) { checkNotNull(email); @@ -303,6 +324,15 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer commit(); } + public void deleteAvatar(String userId) { + checkIsAdmin(); + PollenUser user = getUser0(userId); + if (user.getAvatar() != null) { + getPollenResourceDao().delete(user.getAvatar()); + } + commit(); + } + public PollenEntityRef<PollenResource> setAvatar(ResourceFileBean resourceBean) throws InvalidFormException { checkIsConnected(); resourceBean.setResourceType(ResourceType.AVATAR); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.