This is an automated email from the git hooks/post-receive script. New commit to branch feature/85-droits-utilisateurs in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 9401eb9ab6efc3659e1788d07a8289922abd120b Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Fri Oct 13 15:48:40 2017 +0200 en fonction de la configuration serveur rendre obligatoire la connexion des utilisateur (refs #85) --- .../pollen/rest/api/PollenRestApiApplication.java | 4 + .../rest/api/PollenRestApiRequestFilter.java | 51 ++- .../PollenUnauthorizedExceptionMapper.java | 2 +- .../PollenUserUnknownExceptionMapper.java | 20 + .../org/chorem/pollen/rest/api/v1/AuthApi.java | 3 +- .../pollen/rest/api/v1/ConfigurationApi.java | 29 ++ .../org/chorem/pollen/rest/api/v1/PollApi.java | 2 +- pollen-services/src/main/config/PollenServices.ini | 8 +- .../pollen/services/bean/ConfigurationBean.java | 17 + .../pollen/services/service/ChoiceService.java | 6 + .../pollen/services/service/CommentService.java | 7 + .../services/service/ConfigurationService.java | 17 + .../pollen/services/service/FeedService.java | 2 + .../chorem/pollen/services/service/GtuService.java | 2 + .../pollen/services/service/PollService.java | 33 +- .../services/service/PollenResourceService.java | 7 + .../services/service/PollenServiceSupport.java | 8 + .../pollen/services/service/ReportService.java | 10 + .../pollen/services/service/SocialAuthService.java | 1 + .../services/service/VoteCountingService.java | 1 + .../services/service/VoteCountingTypeService.java | 2 + .../pollen/services/service/VoteService.java | 8 + .../pollen/services/service/VoterListService.java | 15 + .../security/PollenEmailNotValidatedException.java | 2 + .../security/PollenUserBannedException.java | 2 + ...eption.java => PollenUserUnknownException.java} | 8 +- .../services/service/security/SecurityService.java | 11 +- .../i18n/pollen-services_en_GB.properties | 2 + .../i18n/pollen-services_fr_FR.properties | 2 + .../pollen/services/service/PollServiceTest.java | 4 +- pollen-ui-riot-js/package.json | 4 +- pollen-ui-riot-js/src/main/web/home/en.html | 6 +- pollen-ui-riot-js/src/main/web/home/fr.html | 6 +- pollen-ui-riot-js/src/main/web/homeCL/en.html | 6 +- pollen-ui-riot-js/src/main/web/homeCL/fr.html | 6 +- pollen-ui-riot-js/src/main/web/homeCL/offers.html | 6 +- pollen-ui-riot-js/src/main/web/index.js | 2 +- pollen-ui-riot-js/src/main/web/js/AuthService.js | 2 +- .../src/main/web/js/ConfigurationService.js | 33 +- pollen-ui-riot-js/src/main/web/js/FetchService.js | 2 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 2 +- pollen-ui-riot-js/src/main/web/js/Session.js | 45 +-- .../src/main/web/tag/Authorization.tag.html | 69 ++++ .../src/main/web/tag/AvatarAction.tag.js | 20 + .../src/main/web/tag/LinkAction.tag.js | 20 + .../src/main/web/tag/PageChanged.tag.js | 7 + pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 437 +++++++++------------ .../src/main/web/tag/PollenHeader.tag.html | 35 +- .../src/main/web/tag/SignCheck.tag.html | 9 +- pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html | 27 +- pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html | 6 +- .../src/main/web/tag/SigninAction.tag.js | 27 ++ .../src/main/web/tag/UserProfile.tag.html | 8 +- .../web/tag/favoriteList/FavoriteList.tag.html | 8 +- .../favoriteList/FavoriteListEditModal.tag.html | 8 +- .../web/tag/favoriteList/ImportCsvModal.tag.html | 6 +- .../web/tag/favoriteList/ImportLdapModal.tag.html | 6 +- .../src/main/web/tag/poll/EditPoll.tag.html | 8 +- .../src/main/web/tag/poll/Poll.tag.html | 6 +- .../src/main/web/tag/poll/Polls.tag.html | 6 +- .../src/main/web/tag/poll/Summary.tag.html | 4 +- .../src/main/web/tag/voterList/VoterList.tag.html | 4 +- 62 files changed, 716 insertions(+), 411 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java index 8d14605f..b7be3866 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java @@ -35,10 +35,12 @@ import org.chorem.pollen.rest.api.exceptionMappers.PollenInvalidPermissionExcept import org.chorem.pollen.rest.api.exceptionMappers.PollenInvalidSessionTokenExceptionMapper; import org.chorem.pollen.rest.api.exceptionMappers.PollenUnauthorizedExceptionMapper; import org.chorem.pollen.rest.api.exceptionMappers.PollenUserBannedExceptionMapper; +import org.chorem.pollen.rest.api.exceptionMappers.PollenUserUnknownExceptionMapper; import org.chorem.pollen.rest.api.exceptionMappers.TopiaNoResultExceptionMapper; import org.chorem.pollen.rest.api.v1.AuthApi; import org.chorem.pollen.rest.api.v1.ChoiceApi; import org.chorem.pollen.rest.api.v1.CommentApi; +import org.chorem.pollen.rest.api.v1.ConfigurationApi; import org.chorem.pollen.rest.api.v1.DocApi; import org.chorem.pollen.rest.api.v1.FavoriteListApi; import org.chorem.pollen.rest.api.v1.FeedbackApi; @@ -68,6 +70,7 @@ public class PollenRestApiApplication extends Application { new AuthApi(), new ChoiceApi(), new CommentApi(), + new ConfigurationApi(), new DocApi(), new FavoriteListApi(), new PollApi(), @@ -82,6 +85,7 @@ public class PollenRestApiApplication extends Application { new PollenAuthenticationExceptionMapper(), new PollenInvalidSessionTokenExceptionMapper(), new PollenUnauthorizedExceptionMapper(), + new PollenUserUnknownExceptionMapper(), new PollenInvalidPermissionExceptionMapper(), new PollenInvalidEmailActivationTokenExceptionMapper(), new PollenEmailNotValidatedExceptionMapper(), diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java index 35d400d4..e11291d1 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java @@ -31,10 +31,12 @@ import org.chorem.pollen.persistence.PollenPersistenceContext; import org.chorem.pollen.persistence.entity.PollenPrincipal; import org.chorem.pollen.persistence.entity.SessionToken; import org.chorem.pollen.rest.api.v1.AuthApi; +import org.chorem.pollen.services.PollenService; import org.chorem.pollen.services.PollenServiceContext; import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.service.ChoiceService; import org.chorem.pollen.services.service.CommentService; +import org.chorem.pollen.services.service.ConfigurationService; import org.chorem.pollen.services.service.FavoriteListService; import org.chorem.pollen.services.service.FeedService; import org.chorem.pollen.services.service.FeedbackService; @@ -97,6 +99,29 @@ public class PollenRestApiRequestFilter implements ContainerRequestFilter, Conta public static final ImmutableList<Locale> ACCEPT_LANGUAGES = ImmutableList.of(Locale.FRENCH, Locale.ENGLISH); public static final Locale DEFAULT_LANGUAGE = Locale.FRENCH; + public static final ImmutableList<Class<? extends PollenService>> SERVICES = ImmutableList.of( + ChoiceService.class, + CommentService.class, + FavoriteListService.class, + EmailService.class, + NotificationService.class, + FeedService.class, + PollService.class, + SecurityService.class, + ReportService.class, + PollenResourceService.class, + PollenUIUrlRenderService.class, + PollenUserService.class, + VoteCountingService.class, + VoterListService.class, + VoteCountingTypeService.class, + VoteService.class, + PollenUserService.class, + FeedbackService.class, + SocialAuthService.class, + GtuService.class, + ConfigurationService.class); + /** Logger. */ private static final Log log = LogFactory.getLog(PollenRestApiRequestFilter.class); @@ -163,26 +188,12 @@ public class PollenRestApiRequestFilter implements ContainerRequestFilter, Conta serviceContext.setUIContext(extractUIContext(context)); - ResteasyProviderFactory.pushContext(ChoiceService.class, serviceContext.newService(ChoiceService.class)); - ResteasyProviderFactory.pushContext(CommentService.class, serviceContext.newService(CommentService.class)); - ResteasyProviderFactory.pushContext(FavoriteListService.class, serviceContext.newService(FavoriteListService.class)); - ResteasyProviderFactory.pushContext(EmailService.class, serviceContext.newService(EmailService.class)); - ResteasyProviderFactory.pushContext(NotificationService.class, serviceContext.newService(NotificationService.class)); - ResteasyProviderFactory.pushContext(FeedService.class, serviceContext.newService(FeedService.class)); - ResteasyProviderFactory.pushContext(PollService.class, serviceContext.newService(PollService.class)); - ResteasyProviderFactory.pushContext(SecurityService.class, serviceContext.newService(SecurityService.class)); - ResteasyProviderFactory.pushContext(ReportService.class, serviceContext.newService(ReportService.class)); - ResteasyProviderFactory.pushContext(PollenResourceService.class, serviceContext.newService(PollenResourceService.class)); - ResteasyProviderFactory.pushContext(PollenUIUrlRenderService.class, serviceContext.newService(PollenUIUrlRenderService.class)); - ResteasyProviderFactory.pushContext(PollenUserService.class, serviceContext.newService(PollenUserService.class)); - ResteasyProviderFactory.pushContext(VoteCountingService.class, serviceContext.newService(VoteCountingService.class)); - ResteasyProviderFactory.pushContext(VoterListService.class, serviceContext.newService(VoterListService.class)); - ResteasyProviderFactory.pushContext(VoteCountingTypeService.class, serviceContext.newService(VoteCountingTypeService.class)); - ResteasyProviderFactory.pushContext(VoteService.class, serviceContext.newService(VoteService.class)); - ResteasyProviderFactory.pushContext(PollenUserService.class, serviceContext.newService(PollenUserService.class)); - ResteasyProviderFactory.pushContext(FeedbackService.class, serviceContext.newService(FeedbackService.class)); - ResteasyProviderFactory.pushContext(SocialAuthService.class, serviceContext.newService(SocialAuthService.class)); - ResteasyProviderFactory.pushContext(GtuService.class, serviceContext.newService(GtuService.class)); + SERVICES.forEach(serviceClass -> pushService(serviceClass, serviceContext)); + } + + protected <S extends PollenService> void pushService(Class<S> serviceClass, PollenServiceContext serviceContext) { + S service = serviceContext.newService(serviceClass); + ResteasyProviderFactory.pushContext(serviceClass, service); } private PollenUIContext extractUIContext(ContainerRequestContext context) { diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUnauthorizedExceptionMapper.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUnauthorizedExceptionMapper.java index 962413e0..fc9f5b13 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUnauthorizedExceptionMapper.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUnauthorizedExceptionMapper.java @@ -31,6 +31,6 @@ import javax.ws.rs.core.Response; public class PollenUnauthorizedExceptionMapper extends PollenAbstractExceptionMapper<PollenUnauthorizedException> { public PollenUnauthorizedExceptionMapper() { - super(Response.Status.FORBIDDEN); + super(Response.Status.UNAUTHORIZED); } } diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUserUnknownExceptionMapper.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUserUnknownExceptionMapper.java new file mode 100644 index 00000000..d775629b --- /dev/null +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUserUnknownExceptionMapper.java @@ -0,0 +1,20 @@ +package org.chorem.pollen.rest.api.exceptionMappers; + +import org.chorem.pollen.services.service.security.PollenUserUnknownException; + +import javax.ws.rs.core.Response; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class PollenUserUnknownExceptionMapper extends PollenAbstractExceptionMapper<PollenUserUnknownException> { + + public PollenUserUnknownExceptionMapper() { + super(Response.Status.FORBIDDEN); + } + + @Override + protected Object getEntity(PollenUserUnknownException exception) { + return "unknown"; + } +} diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java index 30fcfbc4..089b2894 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java @@ -43,6 +43,7 @@ import org.chorem.pollen.services.service.security.PollenEmailNotValidatedExcept import org.chorem.pollen.services.service.security.PollenInvalidSessionTokenException; import org.chorem.pollen.services.service.security.PollenSecurityContext; import org.chorem.pollen.services.service.security.PollenUserBannedException; +import org.chorem.pollen.services.service.security.PollenUserUnknownException; import org.chorem.pollen.services.service.security.SecurityService; import javax.servlet.http.HttpServletRequest; @@ -238,7 +239,7 @@ public class AuthApi { @Path("/lostpassword") @POST public void lostPassword(@Context SecurityService securityService, - String login) throws PollenEmailNotValidatedException { + String login) throws PollenUserUnknownException, PollenEmailNotValidatedException { securityService.lostPassword(login); diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ConfigurationApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ConfigurationApi.java new file mode 100644 index 00000000..844d5a0d --- /dev/null +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ConfigurationApi.java @@ -0,0 +1,29 @@ +package org.chorem.pollen.rest.api.v1; + +import org.chorem.pollen.services.bean.ConfigurationBean; +import org.chorem.pollen.services.service.ConfigurationService; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +@Path("") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class ConfigurationApi { + + @Path("configuration") + @GET + public ConfigurationBean getConfiguration(@Context ConfigurationService configurationService) { + + return configurationService.getConfiguration(); + + } + +} diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java index 1a28d9f5..50573bcb 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java @@ -192,7 +192,7 @@ public class PollApi { @Path("/polls/{pollId}/assign") @PUT public PollBean assignPoll(@Context PollService pollService, - @PathParam("pollId") PollenEntityId<Poll> pollId) { + @PathParam("pollId") PollenEntityId<Poll> pollId) throws InvalidFormException { return pollService.assignPollToConnectedUser(pollId.getEntityId()); } diff --git a/pollen-services/src/main/config/PollenServices.ini b/pollen-services/src/main/config/PollenServices.ini index 91ebed00..e20ffe6c 100644 --- a/pollen-services/src/main/config/PollenServices.ini +++ b/pollen-services/src/main/config/PollenServices.ini @@ -203,4 +203,10 @@ defaultValue = en description = pollen.configuration.maxVoters key = pollen.default.maxVoters type = int -defaultValue = 0 \ No newline at end of file +defaultValue = 0 + +[option userConnectedRequired] +description = pollen.configuration.userConnectedRequired +key = pollen.default.userConnectedRequired +type = boolean +defaultValue = false \ No newline at end of file diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/ConfigurationBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/ConfigurationBean.java new file mode 100644 index 00000000..ae045eb5 --- /dev/null +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/ConfigurationBean.java @@ -0,0 +1,17 @@ +package org.chorem.pollen.services.bean; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ConfigurationBean { + + protected boolean userConnectedRequired; + + public boolean isUserConnectedRequired() { + return userConnectedRequired; + } + + public void setUserConnectedRequired(boolean userConnectedRequired) { + this.userConnectedRequired = userConnectedRequired; + } +} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java index efdfb276..4a537257 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java @@ -94,6 +94,7 @@ public class ChoiceService extends PollenServiceSupport { } public List<ChoiceBean> getChoices(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); @@ -106,6 +107,7 @@ public class ChoiceService extends PollenServiceSupport { } public ChoiceBean getChoice(String pollId, String choiceId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(choiceId); @@ -119,6 +121,7 @@ public class ChoiceService extends PollenServiceSupport { } public PollenEntityRef<Choice> addChoice(String pollId, ChoiceBean choice) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(choice); @@ -145,6 +148,7 @@ public class ChoiceService extends PollenServiceSupport { } public ChoiceBean editChoice(String pollId, ChoiceBean choice) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(choice); checkIsPersisted(choice); @@ -166,6 +170,7 @@ public class ChoiceService extends PollenServiceSupport { } public void deleteChoice(String pollId, String choiceId) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(choiceId); @@ -366,6 +371,7 @@ public class ChoiceService extends PollenServiceSupport { } public long getChoiceCount(Poll poll) { + checkIsConnectedRequired(); return getChoiceDao().forPollEquals(poll).count(); } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java index 4ff21786..2bfeda2b 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java @@ -86,6 +86,7 @@ public class CommentService extends PollenServiceSupport { }; public PaginationResultBean<CommentBean> getComments(String pollId, PaginationParameterBean paginationParameter) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readComment, pollId); @@ -100,6 +101,7 @@ public class CommentService extends PollenServiceSupport { } public long getCommentCount(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readComment, pollId); @@ -110,6 +112,7 @@ public class CommentService extends PollenServiceSupport { } public CommentBean getNewComment(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.addComment, pollId); @@ -133,6 +136,7 @@ public class CommentService extends PollenServiceSupport { } public CommentBean getComment(String pollId, String commentId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(commentId); @@ -147,6 +151,7 @@ public class CommentService extends PollenServiceSupport { } public PollenEntityRef<Comment> addComment(String pollId, CommentBean comment) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(comment); @@ -168,6 +173,7 @@ public class CommentService extends PollenServiceSupport { } public CommentBean editComment(String pollId, CommentBean comment) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(comment); @@ -189,6 +195,7 @@ public class CommentService extends PollenServiceSupport { } public void deleteComment(String pollId, String commentId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(commentId); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ConfigurationService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ConfigurationService.java new file mode 100644 index 00000000..53253903 --- /dev/null +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ConfigurationService.java @@ -0,0 +1,17 @@ +package org.chorem.pollen.services.service; + +import org.chorem.pollen.services.bean.ConfigurationBean; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ConfigurationService extends PollenServiceSupport { + + public ConfigurationBean getConfiguration() { + ConfigurationBean bean = new ConfigurationBean(); + bean.setUserConnectedRequired(getPollenServiceConfig().isUserConnectedRequired()); + + return bean; + } + +} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java index f05fa12d..11316a40 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FeedService.java @@ -147,6 +147,8 @@ public class FeedService extends PollenServiceSupport { } public String getFeedContentForPoll(String pollId) { + checkIsConnectedRequired(); + checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/GtuService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/GtuService.java index 2198b652..a272404c 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/GtuService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/GtuService.java @@ -98,6 +98,7 @@ public class GtuService extends PollenServiceSupport { } public boolean isGtuValidated(PollenUser user) { + checkIsConnectedRequired(); return isGtuValidatedForDate(user.getGtuValidationDate()); } @@ -109,6 +110,7 @@ public class GtuService extends PollenServiceSupport { } public boolean isGtuValidated(Poll poll) { + checkIsConnectedRequired(); boolean validated; PollenUser user = poll.getCreator().getPollenUser(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index ee82987b..5d72866e 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -43,7 +43,6 @@ import org.chorem.pollen.services.bean.VoterListMemberBean; import org.chorem.pollen.services.bean.export.ExportBean; import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.service.security.PermissionVerb; -import org.chorem.pollen.services.service.security.PollenUnauthorizedException; import org.chorem.pollen.votecounting.VoteCountingNotFound; import org.nuiton.util.pagination.PaginationParameter; import org.nuiton.util.pagination.PaginationResult; @@ -238,6 +237,7 @@ public class PollService extends PollenServiceSupport { } public PollBean getPoll(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); @@ -249,6 +249,7 @@ public class PollService extends PollenServiceSupport { } public PollBean getNewPoll(ChoiceType choiceType) { + checkIsConnectedRequired(); PollBean pollBean = new PollBean(); pollBean.setChoiceType(choiceType); @@ -297,6 +298,7 @@ public class PollService extends PollenServiceSupport { List<ChoiceBean> choices, List<VoterListBean> voterLists, List<VoterListMemberBean> voterListMembers) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(poll); checkIsNotPersisted(poll); @@ -326,6 +328,7 @@ public class PollService extends PollenServiceSupport { } public PollBean editPoll(PollBean poll) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(poll); checkIsPersisted(poll); @@ -355,6 +358,7 @@ public class PollService extends PollenServiceSupport { } public void deletePoll(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.deletePoll, pollId); @@ -370,6 +374,7 @@ public class PollService extends PollenServiceSupport { } public PollenEntityRef<Poll> clonePoll(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.clonePoll, pollId); @@ -408,6 +413,7 @@ public class PollService extends PollenServiceSupport { } public Date closePoll(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.closePoll, pollId); @@ -425,6 +431,7 @@ public class PollService extends PollenServiceSupport { } public void reopenPoll(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.closePoll, pollId); @@ -442,6 +449,7 @@ public class PollService extends PollenServiceSupport { public ExportBean exportPoll(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.exportPoll, pollId); @@ -453,7 +461,7 @@ public class PollService extends PollenServiceSupport { } - public PollBean assignPollToConnectedUser(String pollId) { + public PollBean assignPollToConnectedUser(String pollId) throws InvalidFormException { PollenUser connectedUser = checkAndGetConnectedUser(); @@ -463,17 +471,18 @@ public class PollService extends PollenServiceSupport { Poll poll = getPoll0(pollId); PollenUser creator = poll.getCreator().getPollenUser(); - if (creator != null) { - if (!creator.equals(connectedUser)) { - throw new PollenUnauthorizedException(connectedUser.getEmail()); - } else { - // no poll assigned - return null; - } - } + ErrorMap errorMap = new ErrorMap(); + check(errorMap, + "poll", + creator == null || creator.equals(connectedUser), + l(getLocale(), "pollen.error.poll.assign.already")); - poll.getCreator().setPollenUser(connectedUser); - commit(); + errorMap.failIfNotEmpty(); + + if (creator == null) { + poll.getCreator().setPollenUser(connectedUser); + commit(); + } return toPollBean(poll); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java index 60a7571e..083a5164 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java @@ -83,6 +83,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public ResourceStreamBean getResource(String resourceId) { + checkIsConnectedRequired(); checkNotNull(resourceId); PollenResource resource = getResource0(resourceId); @@ -91,6 +92,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public ResourceMetaBean getMetaResource(String resourceId) { + checkIsConnectedRequired(); checkNotNull(resourceId); PollenResource resource = getResource0(resourceId); @@ -99,6 +101,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public ResourceStreamBean getResourcePreview(String resourceId, boolean maxDimension) { + checkIsConnectedRequired(); checkNotNull(resourceId); @@ -157,6 +160,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public PollenEntityRef<PollenResource> createResource(ResourceFileBean resource) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(resource); checkIsNotPersisted(resource); @@ -174,6 +178,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public PollenResource createAvatarResource(AbstractResourceBean resource) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(resource); checkIsNotPersisted(resource); @@ -185,6 +190,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public void deleteResource(String resourceId) { + checkIsConnectedRequired(); checkNotNull(resourceId); checkIsAdmin(); @@ -200,6 +206,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle } public ResourceStreamBean getAvatar(String userId) { + checkIsConnectedRequired(); PollenResource resource = getPollenResourceDao().findAvatarForUser(userId); return toResourceStreamBean(resource); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java index 06c86f35..e719fa6b 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java @@ -121,6 +121,10 @@ public abstract class PollenServiceSupport implements PollenService { return newService(CommentService.class); } + protected ConfigurationService getConfigurationService() { + return newService(ConfigurationService.class); + } + protected FavoriteListService getFavoriteListService() { return newService(FavoriteListService.class); } @@ -265,6 +269,10 @@ public abstract class PollenServiceSupport implements PollenService { getSecurityService().checkIsConnected(); } + public void checkIsConnectedRequired() { + getSecurityService().checkIsConnectedRequired(); + } + public void checkIsConnected(String userId) { getSecurityService().checkIsConnected(userId); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java index 121fdb7c..815e1707 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java @@ -57,6 +57,7 @@ public class ReportService extends PollenServiceSupport { public void addPollReport(String pollId, ReportBean reportBean) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); @@ -70,6 +71,7 @@ public class ReportService extends PollenServiceSupport { } public List<ReportBean> getPollReports(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); @@ -79,6 +81,7 @@ public class ReportService extends PollenServiceSupport { } public void savePollReport(String pollId, ReportBean reportBean) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); @@ -86,6 +89,7 @@ public class ReportService extends PollenServiceSupport { } public void addChoiceReport(String pollId, String choiceId, ReportBean reportBean) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(choiceId); @@ -102,6 +106,7 @@ public class ReportService extends PollenServiceSupport { } public List<ReportBean> getChoiceReports(String pollId, String choiceId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(choiceId); @@ -112,6 +117,7 @@ public class ReportService extends PollenServiceSupport { } public void saveChoiceReport(String pollId, String choiceId, ReportBean reportBean) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); @@ -119,6 +125,7 @@ public class ReportService extends PollenServiceSupport { } public void addCommentReport(String pollId, String commentId, ReportBean reportBean) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(commentId); @@ -135,6 +142,7 @@ public class ReportService extends PollenServiceSupport { } public List<ReportBean> getCommentReports(String pollId, String commentId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(commentId); @@ -145,6 +153,7 @@ public class ReportService extends PollenServiceSupport { } public void saveCommentReport(String pollId, String commentId, ReportBean reportBean) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); @@ -153,6 +162,7 @@ public class ReportService extends PollenServiceSupport { protected List<ReportBean> getReports(String targetId) { + checkIsConnectedRequired(); checkNotNull(targetId); List<Report> reports = getReportTopiaDao().forTargetIdEquals(targetId).findAll(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/SocialAuthService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/SocialAuthService.java index da9b9bbd..bdcb7991 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/SocialAuthService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/SocialAuthService.java @@ -155,6 +155,7 @@ public class SocialAuthService extends PollenServiceSupport { } public SocialAuthManager getSocialAuthManager() throws Exception { + checkIsConnectedRequired(); //Create an instance of SocialAuthConfgi object SocialAuthConfig config = SocialAuthConfig.getDefault(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java index 4ee03c36..4b2e24e8 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java @@ -64,6 +64,7 @@ import java.util.stream.Collectors; public class VoteCountingService extends PollenServiceSupport { public VoteCountingResultBean getMainResult(String pollId) { + checkIsConnectedRequired(); Preconditions.checkNotNull(pollId); checkPermission(PermissionVerb.readPollResult, pollId); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingTypeService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingTypeService.java index 656c9812..ba7cfc56 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingTypeService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingTypeService.java @@ -39,6 +39,7 @@ import java.util.Locale; public class VoteCountingTypeService extends PollenServiceSupport { public List<VoteCountingTypeBean> getVoteCountingTypes() { + checkIsConnectedRequired(); VoteCountingFactory factory = serviceContext.getVoteCountingFactory(); @@ -54,6 +55,7 @@ public class VoteCountingTypeService extends PollenServiceSupport { } public VoteCountingTypeBean getVoteCountingType(int id) { + checkIsConnectedRequired(); try { return idToVoteCountingType(id); } catch (VoteCountingNotFound e) { diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java index 223a2e42..8fdae9dd 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java @@ -139,6 +139,7 @@ public class VoteService extends PollenServiceSupport { } public VoteBean getNewVote(String pollId) { + checkIsConnectedRequired(); checkPermission(PermissionVerb.addVote, pollId); VoteBean voteBean = new VoteBean(); @@ -191,6 +192,7 @@ public class VoteService extends PollenServiceSupport { } public PaginationResultBean<VoteBean> getVotes(String pollId, PaginationParameterBean paginationParameter) { + checkIsConnectedRequired(); checkNotNull(pollId); @@ -206,6 +208,7 @@ public class VoteService extends PollenServiceSupport { } public VoteBean getVote(String pollId, String voteId) { + checkIsConnectedRequired(); checkNotNull(voteId); checkPermission(PermissionVerb.readVote, voteId); @@ -219,6 +222,7 @@ public class VoteService extends PollenServiceSupport { } public PollenEntityRef<Vote> addVote(String pollId, VoteBean vote) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(vote); @@ -251,6 +255,7 @@ public class VoteService extends PollenServiceSupport { } public VoteBean editVote(String pollId, VoteBean vote) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(vote); checkIsPersisted(vote); @@ -273,6 +278,7 @@ public class VoteService extends PollenServiceSupport { } public void deleteVote(String pollId, String voteId) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(voteId); @@ -543,6 +549,8 @@ public class VoteService extends PollenServiceSupport { } public long getVoteCount(Poll poll) { + checkIsConnectedRequired(); + return getVoteDao().forPollEquals(poll).count(); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java index eb9a3833..1548a466 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java @@ -155,6 +155,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListBean toVoterListBean(VoterList entity) { + checkIsConnectedRequired(); VoterListBean bean = new VoterListBean(); bean.setEntityId(entity.getTopiaId()); @@ -180,6 +181,7 @@ public class VoterListService extends PollenServiceSupport { } public List<VoterListBean> getVoterLists(String pollId, String parentId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); @@ -191,6 +193,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListBean getMainVoterList(String pollId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.readPoll, pollId); @@ -209,6 +212,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListBean getVoterList(String pollId, String voterListId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(voterListId); @@ -222,6 +226,7 @@ public class VoterListService extends PollenServiceSupport { public PollenEntityRef<VoterList> addVoterList(String pollId, VoterListBean voterList, List<VoterListMemberBean> members) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(voterList); checkIsNotPersisted(voterList); @@ -238,6 +243,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListBean editVoterList(String pollId, VoterListBean voterList) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(voterList); checkIsPersisted(voterList); @@ -256,6 +262,7 @@ public class VoterListService extends PollenServiceSupport { } public void deleteVoterList(String pollId, String voterListId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(voterListId); @@ -270,6 +277,7 @@ public class VoterListService extends PollenServiceSupport { } public Set<VoterListMemberBean> getVoterListMembers(String pollId, String voterListId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(voterListId); @@ -283,6 +291,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListMemberBean getVoterListMember(String pollId, String voterListId, String memberId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkNotNull(voterListId); @@ -297,6 +306,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListMemberBean addVoterListMember(String pollId, VoterListMemberBean member) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(member); checkIsNotPersisted(member); @@ -312,6 +322,7 @@ public class VoterListService extends PollenServiceSupport { } public VoterListMemberBean editVoterListMember(String pollId, VoterListMemberBean member) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(member); checkIsPersisted(member); @@ -329,6 +340,7 @@ public class VoterListService extends PollenServiceSupport { public void deleteVoterListMember(String pollId, String voterListId, String memberId) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(voterListId); checkNotNull(memberId); @@ -572,6 +584,7 @@ public class VoterListService extends PollenServiceSupport { List<VoterListMemberBean> membersToSave, List<String> listIdsToDelete, List<String> memberIdsToDelete) throws InvalidFormException { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); @@ -781,6 +794,7 @@ public class VoterListService extends PollenServiceSupport { } public int resendInvitationVoterList(String pollId, String voterListId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); @@ -795,6 +809,7 @@ public class VoterListService extends PollenServiceSupport { } public boolean resendInvitationMember(String pollId, String voterListId, String memberId) { + checkIsConnectedRequired(); checkNotNull(pollId); checkPermission(PermissionVerb.editPoll, pollId); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java index e978b5d0..370e92a0 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java @@ -28,6 +28,8 @@ package org.chorem.pollen.services.service.security; */ public class PollenEmailNotValidatedException extends Exception { + private static final long serialVersionUID = -895891067610883986L; + public PollenEmailNotValidatedException() { super("emailNotValidated"); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java index c49549a5..4d6ebaf9 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java @@ -28,6 +28,8 @@ package org.chorem.pollen.services.service.security; */ public class PollenUserBannedException extends Exception { + private static final long serialVersionUID = 6374948901769220215L; + public PollenUserBannedException() { super("userBanned"); } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserUnknownException.java similarity index 82% copy from pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java copy to pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserUnknownException.java index e978b5d0..2c61ddeb 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserUnknownException.java @@ -26,9 +26,11 @@ package org.chorem.pollen.services.service.security; * * @author Kevin Morin - morin@codelutin.com */ -public class PollenEmailNotValidatedException extends Exception { +public class PollenUserUnknownException extends Exception { - public PollenEmailNotValidatedException() { - super("emailNotValidated"); + private static final long serialVersionUID = 6374948901769220215L; + + public PollenUserUnknownException() { + super("userUnknown"); } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java index 752e606b..daabb188 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java @@ -116,6 +116,13 @@ public class SecurityService extends PollenServiceSupport { } @Override + public void checkIsConnectedRequired() { + if (getPollenServiceConfig().isUserConnectedRequired()) { + checkIsConnected(); + } + } + + @Override public void checkIsConnected(String userId) { PollenSecurityContext securityContext = getSecurityContext(); @@ -203,14 +210,14 @@ public class SecurityService extends PollenServiceSupport { getSecurityContext().setSessionToken(null); } - public void lostPassword(String login) throws PollenEmailNotValidatedException { + public void lostPassword(String login) throws PollenUserUnknownException, PollenEmailNotValidatedException { Preconditions.checkNotNull(login); PollenUser user = getPollenUserDao().forEmailEquals(login).findUniqueOrNull(); if (user == null) { - throw new PollenUnauthorizedException(login); + throw new PollenUserUnknownException(); } if (!user.isEmailValidated()) { diff --git a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties index 5680fe60..b7ef292e 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties @@ -40,6 +40,7 @@ pollen.configuration.smtpPort=Smtp Port pollen.configuration.uiEndPoint=Ui end point pollen.configuration.uiUrlPollEdit=Url to edit a poll pollen.configuration.uiUrlPollVote=Url to vote on a poll +pollen.configuration.userConnectedRequired=Only connected users can be access on application pollen.configuration.version=Application version pollen.configurqtion.uiUrlPollVoteEdit=Url to edit a vote on a poll pollen.configurqtion.uiUrlUserValidate=Url de validate user account @@ -76,6 +77,7 @@ pollen.error.favoriteListMember.name.empty=member name can not be empty pollen.error.favoriteListMember.weight.negativeOrNull=Weight (%s) must be positive pollen.error.import.favoriteList.parser=Bad structure file \: %s pollen.error.import.favoriteList.version=import file version (%s) is not correct +pollen.error.poll.assign.already=Poll already assign to other user pollen.error.poll.beginChoiceDate.afterEndDate=the begin date of adding choice is after the end of poll pollen.error.poll.choice.mandatory=At least a choice is mandatory pollen.error.poll.choiceType.mandatory= diff --git a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties index 615a21a6..14b3b40d 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties @@ -40,6 +40,7 @@ pollen.configuration.smtpPort=Port smtp pollen.configuration.uiEndPoint=End point de l'ui pollen.configuration.uiUrlPollEdit=Url d'édition d'un sondage pollen.configuration.uiUrlPollVote=Url de vote sur un sondage +pollen.configuration.userConnectedRequired=Seul les utilisateurs connectés peuvent accéder à l'application pollen.configuration.version=Version de l'application pollen.configurqtion.uiUrlPollVoteEdit=Url d'édition de vote sur un sondage pollen.configurqtion.uiUrlUserValidate=Url de validation d'un compte utilisateur @@ -76,6 +77,7 @@ pollen.error.favoriteListMember.name.empty=Le nom du membre est obligatoire pollen.error.favoriteListMember.weight.negativeOrNull=le poids du membre (%s) doit être positif pollen.error.import.favoriteList.parser=Fichier mal structuré \: %s pollen.error.import.favoriteList.version=Le version du fichier d'import (%s) n'est pas correcte +pollen.error.poll.assign.already=Le sondage est déjà associé à un autre utilisateur pollen.error.poll.beginChoiceDate.afterEndDate=La date de début d'ajout de choix est après la date de fin du sondage pollen.error.poll.choice.mandatory=Au moins un choix est nécessaire pollen.error.poll.choiceType.mandatory= diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java index 527aa601..48a3007e 100644 --- a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java +++ b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java @@ -538,7 +538,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { // } @Test - public void testAssignPollToConnectedUser() throws PollenInvalidSessionTokenException, PollenAuthenticationException, PollenEmailNotValidatedException, PollenUserBannedException { + public void testAssignPollToConnectedUser() throws PollenInvalidSessionTokenException, InvalidFormException, PollenAuthenticationException, PollenEmailNotValidatedException, PollenUserBannedException { Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID); Assert.assertNull(poll.getCreator().getPollenUser()); try { @@ -570,7 +570,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { service.assignPollToConnectedUser(poll.getTopiaId()); Assert.fail("An error should be thrown as the poll is already assigned to a user"); - } catch (PollenUnauthorizedException e) { + } catch (InvalidFormException e) { Assert.assertNotNull(pollenUser); Assert.assertEquals("tony@pollen.fake", pollenUser.getEmail()); } diff --git a/pollen-ui-riot-js/package.json b/pollen-ui-riot-js/package.json index 8a8a684d..30bdeb36 100644 --- a/pollen-ui-riot-js/package.json +++ b/pollen-ui-riot-js/package.json @@ -45,13 +45,13 @@ "console.history": "^1.5.0", "font-awesome": "4.7.0", "html2canvas": "^0.5.0-beta4", - "moment": "^2.17.1", + "moment": "^2.19.1", "moment-timezone": "^0.5.13", "nprogress": "^0.2.0", "object.values": "^1.0.4", "qrcode-generator": "^1.3.0", "remarkable": "^1.7.1", "riot": "^3.6.1", - "riot-route": "^2.5.0" + "riot-route": "^3.1.2" } } diff --git a/pollen-ui-riot-js/src/main/web/home/en.html b/pollen-ui-riot-js/src/main/web/home/en.html index 499f5a66..249666b3 100644 --- a/pollen-ui-riot-js/src/main/web/home/en.html +++ b/pollen-ui-riot-js/src/main/web/home/en.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -24,7 +24,7 @@ <div class="home-container"> <div class="wrapper"> <div> - <a class="c-button c-button--ghost u-xlarge c-button--ghost-info" href="#/poll/new/text"> + <a class="c-button c-button--ghost u-xlarge c-button--ghost-info" href="#poll/new/text"> <i class="fa fa-list-ol"></i> New poll </a> </div> diff --git a/pollen-ui-riot-js/src/main/web/home/fr.html b/pollen-ui-riot-js/src/main/web/home/fr.html index f3238175..65701922 100644 --- a/pollen-ui-riot-js/src/main/web/home/fr.html +++ b/pollen-ui-riot-js/src/main/web/home/fr.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -24,7 +24,7 @@ <div class="home-container"> <div class="wrapper"> <div> - <a class="c-button c-button--ghost u-xlarge c-button--ghost-info" href="#/poll/new/text"> + <a class="c-button c-button--ghost u-xlarge c-button--ghost-info" href="#poll/new/text"> <i class="fa fa-list-ol"></i> Nouveau Sondage </a> </div> diff --git a/pollen-ui-riot-js/src/main/web/homeCL/en.html b/pollen-ui-riot-js/src/main/web/homeCL/en.html index c32c31b0..7bee986f 100644 --- a/pollen-ui-riot-js/src/main/web/homeCL/en.html +++ b/pollen-ui-riot-js/src/main/web/homeCL/en.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -25,7 +25,7 @@ <div class="sub-header"> <div> - <a class="c-button u-xlarge c-button--info" href="#/poll/new/text"> + <a class="c-button u-xlarge c-button--info" href="#poll/new/text"> <i class="fa fa-list-ol"></i> New Poll </a> </div> diff --git a/pollen-ui-riot-js/src/main/web/homeCL/fr.html b/pollen-ui-riot-js/src/main/web/homeCL/fr.html index 4deabc26..50c1592b 100644 --- a/pollen-ui-riot-js/src/main/web/homeCL/fr.html +++ b/pollen-ui-riot-js/src/main/web/homeCL/fr.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -25,7 +25,7 @@ <div class="sub-header"> <div> - <a class="c-button u-xlarge c-button--info" href="#/poll/new/text"> + <a class="c-button u-xlarge c-button--info" href="#poll/new/text"> <i class="fa fa-list-ol"></i> Nouveau Sondage </a> </div> diff --git a/pollen-ui-riot-js/src/main/web/homeCL/offers.html b/pollen-ui-riot-js/src/main/web/homeCL/offers.html index ab5ecb3f..1b9d5b90 100644 --- a/pollen-ui-riot-js/src/main/web/homeCL/offers.html +++ b/pollen-ui-riot-js/src/main/web/homeCL/offers.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -26,7 +26,7 @@ <h2>Offre Standard</h2> <p> Utilisez librement pollen pour vos sondages personels jusqu'à 100 votants ! - Creez dès à présent un nouveau sondage, quelques <a href="#/poll/new/text">clics</a> suffisent ! + Creez dès à présent un nouveau sondage, quelques <a href="#poll/new/text">clics</a> suffisent ! </p> <p> Vous souhaitez permettre à vos utilisateurs de répondre et voir les résultats d'un sondage directement sur votre site internet ? diff --git a/pollen-ui-riot-js/src/main/web/index.js b/pollen-ui-riot-js/src/main/web/index.js index 30945fa3..1a5e3107 100644 --- a/pollen-ui-riot-js/src/main/web/index.js +++ b/pollen-ui-riot-js/src/main/web/index.js @@ -26,5 +26,5 @@ riot.mixin({logger: require("./js/Logger")}); require("./tag/Pollen.tag.html"); riot.mount("*"); -let route = require("riot-route"); +let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; route.start(true); diff --git a/pollen-ui-riot-js/src/main/web/js/AuthService.js b/pollen-ui-riot-js/src/main/web/js/AuthService.js index 7fd0dbd5..51475f0a 100644 --- a/pollen-ui-riot-js/src/main/web/js/AuthService.js +++ b/pollen-ui-riot-js/src/main/web/js/AuthService.js @@ -84,7 +84,7 @@ class AuthService extends FetchService { } getLoginProviderUrl(providerId, redirection) { - return this.get("/v1/login/" + providerId, { providerRedirection: redirection}); + return this.get("/v1/login/" + providerId, {providerRedirection: redirection}); } signInProvider(query) { diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java b/pollen-ui-riot-js/src/main/web/js/ConfigurationService.js similarity index 61% copy from pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java copy to pollen-ui-riot-js/src/main/web/js/ConfigurationService.js index e978b5d0..54777d38 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenEmailNotValidatedException.java +++ b/pollen-ui-riot-js/src/main/web/js/ConfigurationService.js @@ -1,34 +1,37 @@ -package org.chorem.pollen.services.service.security; - -/* +/*- * #%L - * Pollen :: Service + * Pollen :: UI (Riot Js) * %% - * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit + * Copyright (C) 2009 - 2017 CodeLutin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ +let singleton = require("./Singleton"); +let FetchService = require("./FetchService"); -/** - * Error thrown when the user tires to login although he has not yet validated his email. - * - * @author Kevin Morin - morin@codelutin.com - */ -public class PollenEmailNotValidatedException extends Exception { +class ConfigurationService extends FetchService { + + _getUrlPrefix() { + let url = "/v1/configuration"; + return url; + } - public PollenEmailNotValidatedException() { - super("emailNotValidated"); + getConfiguration() { + let url = this._getUrlPrefix(); + return this.get(url); } } + +module.exports = singleton(ConfigurationService); diff --git a/pollen-ui-riot-js/src/main/web/js/FetchService.js b/pollen-ui-riot-js/src/main/web/js/FetchService.js index 637f7e28..93778d5f 100644 --- a/pollen-ui-riot-js/src/main/web/js/FetchService.js +++ b/pollen-ui-riot-js/src/main/web/js/FetchService.js @@ -51,7 +51,7 @@ class FetchService { } if (response.status === 200) { let responseCopy = response.clone(); - return responseCopy.json().catch(err => { + return responseCopy.json().catch(() => { return response.text(); }); } diff --git a/pollen-ui-riot-js/src/main/web/js/PollForm.js b/pollen-ui-riot-js/src/main/web/js/PollForm.js index 97c90b8d..996d8f78 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -20,7 +20,7 @@ */ let singleton = require("./Singleton"); let Choice = require("./Choice"); -let route = require("riot-route"); +let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; let voteCountingTypeService = require("./VoteCountingTypeService"); let choiceService = require("./ChoiceService"); let resourceService = require("./ResourceService"); diff --git a/pollen-ui-riot-js/src/main/web/js/Session.js b/pollen-ui-riot-js/src/main/web/js/Session.js index e1c16257..8dce67bf 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -22,6 +22,7 @@ let singleton = require("./Singleton"); let authService = require("./AuthService"); let resourceService = require("./ResourceService"); +let configurationService = require("./ConfigurationService"); let bus = require("./PollenBus.js"); let logger = require("./Logger"); let pageTracker = require("./PageTracker"); @@ -49,7 +50,7 @@ class Session { resourceUrl: this.configuration.endPoint + "/v1/resources/{resourceId}", resourceDownloadUrl: this.configuration.endPoint + "/v1/resources/{resourceId}/download", profileUrl: window.location.origin + "/#user/profile", - offersUrl: window.location.origin + "/#home" + offersUrl: window.location.origin + "/#" }; // pour contenir les traductions this.i18n = { @@ -90,19 +91,31 @@ class Session { } start() { + this.updateConfigurationServer(); this.updateUser(); this.updateGtu(); } + updateConfigurationServer() { + this.configurationServerPromise = configurationService.getConfiguration(); + this.configurationServerPromise.then(result => { + this.configurationServer = result; + return this; + }); + } + updateUser() { if (this.isConnected()) { - this.connect().then(user => { + this.userPromise = this.connect(); + this.userPromise.then(user => { var oldUser = this.user; this.user = user; bus.trigger("user", user, oldUser); - }).catch(() => { + }, () => { bus.trigger("userNoMoreConnected"); }); + } else { + this.userPromise = Promise.reject(); } } @@ -131,24 +144,10 @@ class Session { return document.cookie.indexOf("pollen-connected=true") !== -1; } - isAdminConnected(callback, fallback) { - let userConnectedCallback = (user) => { - if (user.administrator) { - callback(); - } else { - fallback(); - } - bus.off("user", this); - }; - if (this.isConnected()) { - if (this.user) { - userConnectedCallback(this.user); - } else { - bus.on("user", userConnectedCallback); - } - } else { - fallback(); - } + isAdminConnected() { + return this.userPromise.then((user) => { + return Promise.resolve(user.administrator); + }); } connect() { @@ -179,7 +178,8 @@ class Session { updateConnection(auth, session) { logger.info("SignIn::"); logger.info(auth); - return authService.userPromise(auth).then((user) => { + this.userPromise = authService.userPromise(auth); + return this.userPromise.then((user) => { if (!user) { logger.info("SignIn error"); let oldUser = session.user; @@ -202,6 +202,7 @@ class Session { return authService.signOut().then(() => { var oldUser = this.user; this.user = null; + this.userPromise = Promise.reject(); bus.trigger("user", this.user, oldUser); return this.user; }); diff --git a/pollen-ui-riot-js/src/main/web/tag/Authorization.tag.html b/pollen-ui-riot-js/src/main/web/tag/Authorization.tag.html new file mode 100644 index 00000000..80384688 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/Authorization.tag.html @@ -0,0 +1,69 @@ +<Authorization> + <div if={authorized}> + <yield/> + </div> + + <script type="es6"> + let session = require("../js/Session"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi + this.authorized = false; + this.routeArguments = []; + + this.connectedIfRequiredPromise = () => { + return session.configurationServerPromise.then(configurationServer => { + if (configurationServer.userConnectedRequired) { + return session.userPromise.then(() => true, () => false); + } + return true; + }); + }; + + this.adminConnectedPromise = () => { + return session.userPromise.then(user => user.administrator, () => false); + }; + + this.connectedPromise = () => { + return session.userPromise.then(() => true, () => false); + }; + + this.updateAuthorization = () => { + let authorizationPromise; + if (this.opts.admin) { + authorizationPromise = this.adminConnectedPromise(); + } else if (this.opts.connected) { + authorizationPromise = this.connectedPromise(); + } else if (this.opts.connectedIfRequired) { + authorizationPromise = this.connectedIfRequiredPromise(); + } else { + authorizationPromise = Promise.resolve(true); + } + + Promise.all([this.argumentsPromise, authorizationPromise]).then(result => { + this.routeArguments = result[0]; + if (result[1]) { + this.authorized = true; + this.update(); + } else { + this.authorized = false; + if (!location.hash.startsWith("#signin?hash=")) { + route("signin?hash=" + (location.hash && location.hash.substring(1))); + } + } + }); + }; + + this.argumentsPromise = new Promise(resolve => { + this.argumentsResolve = resolve; + }); + + this.updateAuthorization(); + + this.on("route", (...args) => { + this.argumentsResolve(args); + }); + + this.listen("user", this.updateAuthorization); + + </script> + +</Authorization> diff --git a/pollen-ui-riot-js/src/main/web/tag/AvatarAction.tag.js b/pollen-ui-riot-js/src/main/web/tag/AvatarAction.tag.js new file mode 100644 index 00000000..f3d184b7 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/AvatarAction.tag.js @@ -0,0 +1,20 @@ +let riot = require("riot"); +let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; +let session = require("../js/Session"); +let userService = require("../js/UserService"); + +riot.tag("avataraction", false, function() { + + var q = route.query(); + if (q.loginProvider != null && session.isConnected()) { + session.userPromise.then(() => { + userService.setProviderAvatar(q).then(() => { + location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile"); + }, (e) => { + e.text().then(label => { + location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile?error=" + label); + }); + }); + }); + } +}); diff --git a/pollen-ui-riot-js/src/main/web/tag/LinkAction.tag.js b/pollen-ui-riot-js/src/main/web/tag/LinkAction.tag.js new file mode 100644 index 00000000..639b9f96 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/LinkAction.tag.js @@ -0,0 +1,20 @@ +let riot = require("riot"); +let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; +let session = require("../js/Session"); +let userService = require("../js/UserService"); + +riot.tag("linkaction", false, function() { + + var q = route.query(); + if (q.loginProvider != null && session.isConnected()) { + session.userPromise.then(() => { + userService.linkProvider(q).then(() => { + location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile"); + }, (e) => { + e.text().then(label => { + location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile?error=" + label); + }); + }); + }); + } +}); diff --git a/pollen-ui-riot-js/src/main/web/tag/PageChanged.tag.js b/pollen-ui-riot-js/src/main/web/tag/PageChanged.tag.js new file mode 100644 index 00000000..c60ef42c --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/PageChanged.tag.js @@ -0,0 +1,7 @@ +let riot = require("riot"); + +riot.tag("pagechanged", false, function(opts) { + + this.bus.trigger("pageChanged", opts.page); + +}); diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html index b192e896..980e66ee 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html @@ -10,17 +10,18 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% */ require("./PollenWaiter.tag.html"); +require("./Authorization.tag.html"); require("./PollenHeader.tag.html"); require("./PollenFooter.tag.html"); require("./PollenMessageManager.tag.html"); @@ -29,6 +30,10 @@ require("./SignUp.tag.html"); require("./SignCheck.tag.html"); require("./Home.tag.html"); require("./Privacy.tag.html"); +require("./PageChanged.tag.js"); +require("./SigninAction.tag.js"); +require("./AvatarAction.tag.js"); +require("./LinkAction.tag.js"); require("./poll/EditPoll.tag.html"); require("./poll/Poll.tag.html"); require("./poll/Summary.tag.html"); @@ -49,7 +54,192 @@ require("./popup/GtuChangeModal.tag.html"); <PollenHeader/> <PollenWaiter parent-id="body-content"/> <div id="body-content" class="body-content"> - <div ref="content" show="{showContent}"></div> + <router> + <route path="signup/validate"> + <Authorization> + <PageChanged page="signup"/> + <Signup validate="true"/> + </Authorization> + </route> + + <route path="signcheck/*/*"> + <Authorization> + <PageChanged page="signcheck"/> + <Signcheck user-id={routeArguments[0]} + token={routeArguments[1]}/> + </Authorization> + </route> + + <route path="privacy"> + <Authorization> + <PageChanged page="privacy"/> + <Privacy/> + </Authorization> + </route> + + <route path=""> + <Authorization connected-if-required="true"> + <Home/> + </Authorization> + </route> + + <route path="poll/*/vote"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]} + tab-name="votes" /> + </Authorization> + </route> + <route path="poll/*/vote/*"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]} + tab-name="votes" + permission={routeArguments[1]}/> + </Authorization> + </route> + <route path="poll/*/vote/*/*"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]} + tab-name="votes" + vote-id={routeArguments[1]} + permission={routeArguments[2]}/> + </Authorization> + </route> + + <route path="poll/*/result"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]} + tab-name="results" /> + </Authorization> + </route> + <route path="poll/*/result/*"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]} + tab-name="results" + permission={routeArguments[1]}/> + </Authorization> + </route> + + <route path="poll/new/*"> + <Authorization connected-if-required="true"> + <PageChanged page="newPoll"/> + <EditPoll choice-type={routeArguments[0]}/> + </Authorization> + </route> + + <route path="poll/*/edit/*"> + <Authorization connected-if-required="true"> + <PageChanged page="editPoll"/> + <EditPoll poll-id={routeArguments[0]} + permission={routeArguments[1]}/> + </Authorization> + </route> + <route path="poll/*/clone/*"> + <Authorization connected-if-required="true"> + <PageChanged page="editPoll"/> + <EditPoll poll-id={routeArguments[0]} + permission={routeArguments[1]} + clone={true}/> + </Authorization> + </route> + <route path="poll/*/summary/*"> + <Authorization connected-if-required="true"> + <EditPoll poll-id={routeArguments[0]} + permission={routeArguments[1]} + show-summary={true}/> + </Authorization> + </route> + + <route path="poll/*"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]}/> + </Authorization> + </route> + + <route path="poll/*/*"> + <Authorization connected-if-required="true"> + <Poll poll-id={routeArguments[0]} + permission={routeArguments[1]}/> + </Authorization> + </route> + + <route path="polls/created"> + <Authorization connected="true"> + <PageChanged page="createdPolls"/> + <Polls method="createdPolls"/> + </Authorization> + </route> + <route path="polls/invited"> + <Authorization connected="true"> + <PageChanged page="invitedPolls"/> + <Polls method="invitedPolls"/> + </Authorization> + </route> + <route path="polls/participated"> + <Authorization connected="true"> + <PageChanged page="participatedPolls"/> + <Polls method="participatedPolls"/> + </Authorization> + </route> + <route path="polls"> + <Authorization admin="true"> + <PageChanged page="admin_polls"/> + <Polls method="polls"/> + </Authorization> + </route> + + <route path="users"> + <Authorization admin="true"> + <PageChanged page="admin_users"/> + <Users/> + </Authorization> + </route> + + <route path="gtus"> + <Authorization admin="true"> + <PageChanged page="admin_gtus"/> + <Gtus/> + </Authorization> + </route> + <route path="loginProviders"> + <Authorization admin="true"> + <PageChanged page="loginProviders"/> + <LoginProviders/> + </Authorization> + </route> + + <route path="user/profile"> + <Authorization connected="true"> + <PageChanged page="userProfile"/> + <UserProfile/> + </Authorization> + </route> + + <route path="favoriteLists"> + <Authorization connected="true"> + <PageChanged page="favoriteLists"/> + <FavoriteLists/> + </Authorization> + </route> + + <route path="favoriteLists/*"> + <Authorization connected="true"> + <PageChanged page="favoriteLists"/> + <FavoriteList favorite-list-id={routeArguments[0]}/> + </Authorization> + </route> + + <route path="signin.."> + <SignInAction/> + </route> + + <route path="avatar"> + <AvatarAction/> + </route> + + <route path="link"> + <LinkAction/> + </route> + </router> <SignIn ref="signIn"/> </div> @@ -63,7 +253,6 @@ require("./popup/GtuChangeModal.tag.html"); session.start(); this.pageTitle = undefined; - let userService = require("../js/UserService"); this.onLocaleChange = () => { this.updatePageTitle(); @@ -79,24 +268,14 @@ require("./popup/GtuChangeModal.tag.html"); this.updatePageTitle(); }); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; let Message = require("../js/Message"); - this.showContent = true; - this.on("mount", () => { this.listen("locale", this.onLocaleChange); this.listen("unauthorize", this.refs.signIn.open); this.listen("signIn", this.refs.signIn.open); this.listen("closeSignIn", this.refs.signIn.close); - this.listen("signInOpen", () => { - this.showContent = false; - this.update(); - }); - this.listen("signInClosed", () => { - this.showContent = true; - this.update(); - }); this.listen("messageManagerReady", () => { let q = route.query(); if (q.error) { @@ -105,234 +284,6 @@ require("./popup/GtuChangeModal.tag.html"); }); }); - route("/poll/create", () => { - this.bus.trigger("pageChanged", "home"); - riot.mount(this.refs.content, "createpoll"); - }); - - route("/signup", () => { - this.bus.trigger("pageChanged", "signup"); - riot.mount(this.refs.content, "signup"); - }); - - route("/signup/validate", () => { - this.bus.trigger("pageChanged", "signup"); - riot.mount(this.refs.content, "signup", {validate: true}); - }); - - route("/signcheck/*/*", (userId, token) => { - this.bus.trigger("pageChanged", "signcheck"); - riot.mount(this.refs.content, "signcheck", {userId: userId, token: token}); - }); - - route("/poll/created", () => { - if (!session.isConnected()) { - route("/signin?url=/poll/created"); - } else { - this.bus.trigger("pageChanged", "createdPolls"); - riot.mount(this.refs.content, "polls", {method: "createdPolls", session: session}); - } - }); - - route("/poll/invited", () => { - if (!session.isConnected()) { - route("/signin?url=/poll/invited"); - } else { - this.bus.trigger("pageChanged", "invitedPolls"); - riot.mount(this.refs.content, "polls", {method: "invitedPolls", session: session}); - } - }); - - route("/poll/participated", () => { - if (!session.isConnected()) { - route("/signin?url=/poll/participated"); - } else { - this.bus.trigger("pageChanged", "participatedPolls"); - riot.mount(this.refs.content, "polls", {method: "participatedPolls", session: session}); - } - }); - - route("/poll", () => { - session.isAdminConnected(() => { - this.bus.trigger("pageChanged", "admin_polls"); - riot.mount(this.refs.content, "polls", {method: "polls", session: session}); - }, () => { - route("/signin?url=/poll"); - }); - }); - - route("/user", () => { - session.isAdminConnected(() => { - this.bus.trigger("pageChanged", "admin_users"); - riot.mount(this.refs.content, "users", {session: session}); - }, () => { - route("/signin?url=/user"); - }); - }); - - route("/gtu", () => { - session.isAdminConnected(() => { - this.bus.trigger("pageChanged", "admin_gtus"); - riot.mount(this.refs.content, "gtus", {session: session}); - }, () => { - route("/signin?url=/user"); - }); - }); - - route("/poll/*/choice", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "choices"}); - }); - route("/poll/*/choice/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "choices", permission: permission}); - }); - route("/poll/*/vote", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "votes"}); - }); - route("/poll/*/vote/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "votes", permission: permission}); - }); - route("/poll/*/vote/*/*", (pollId, voteId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "votes", voteId: voteId, permission: permission}); - }); - route("/poll/*/comment", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "comments"}); - }); - route("/poll/*/comment/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "comments", permission: permission}); - }); - route("/poll/*/result", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "results"}); - }); - route("/poll/*/result/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "results", permission: permission}); - }); - route("/poll/*/settings", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "settings"}); - }); - route("/poll/*/settings/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "settings", permission: permission}); - }); - route("/poll/new/*", (choiceType) => { - this.bus.trigger("pageChanged", "newPoll"); - riot.mount(this.refs.content, "editpoll", {choiceType: choiceType.toUpperCase()}); - }); - route("/poll/*/edit/*", (pollId, permission) => { - this.bus.trigger("pageChanged", "editPoll"); - riot.mount(this.refs.content, "editpoll", {pollId: pollId, permission: permission}); - }); - route("/poll/*/clone/*", (pollId, permission) => { - this.bus.trigger("pageChanged", "editPoll"); - riot.mount(this.refs.content, "editpoll", {pollId: pollId, permission: permission, clone: true}); - }); - route("/poll/*/summary/*", (pollId, permission) => { - riot.mount(this.refs.content, "editpoll", {pollId: pollId, permission: permission, showSummary: true}); - }); - route("/poll/*", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId}); - }); - - route("/poll/*/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, permission: permission}); - }); - - route("/user/profile", () => { - if (!session.isConnected()) { - route("/signin?url=/user/profile"); - } else { - this.bus.trigger("pageChanged", "userProfile"); - riot.mount(this.refs.content, "userprofile"); - } - }); - route("/favoriteLists", () => { - this.bus.trigger("pageChanged", "favoriteLists"); - riot.mount(this.refs.content, "favoritelists"); - }); - route("/favoriteLists/new", () => { - this.bus.trigger("pageChanged", "favoriteLists"); - riot.mount(this.refs.content, "favoritelist"); - }); - route("/favoriteLists/*", (favoriteListId) => { - this.bus.trigger("pageChanged", "favoriteLists"); - riot.mount(this.refs.content, "favoritelist", {favoriteListId: favoriteListId}); - }); - - route("/loginProviders", () => { - session.isAdminConnected(() => { - this.bus.trigger("pageChanged", "loginProviders"); - riot.mount(this.refs.content, "loginproviders"); - }, () => { - route("/signin?url=/loginProviders"); - }); - }); - - route("/privacy", () => { - this.bus.trigger("pageChanged", "privacy"); - riot.mount(this.refs.content, "privacy"); - }); - - route(() => { - var q = route.query(); - if (q.loginProvider != null) { - if (q.action === "signin") { - session.signInProvider(q).then(() => { - let currentPage = localStorage.getItem("currentPage"); - localStorage.removeItem("currentPage"); - location.replace(session.pollenUIContext.uiEndPoint + "/" + currentPage); - }, (e) => { - let currentPage = localStorage.getItem("currentPage"); - localStorage.removeItem("currentPage"); - e.text().then(label => { - location.replace(session.pollenUIContext.uiEndPoint + "/" + currentPage + "?error=" + label); - }); - }); - - } else if (q.action === "link" && session.isConnected()) { - let callback = (user) => { - userService.linkProvider(q).then(() => { - location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile"); - }, (e) => { - e.text().then(label => { - location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile?error=" + label); - }); - }); - }; - - if (session.getUser()) { - callback(session.getUser()); - } else { - this.bus.on("user", (user) => { - callback(user); - this.bus.off("user", callback); - }); - } - - } else if (q.action === "avatar" && session.isConnected()) { - let callback = (user) => { - userService.setProviderAvatar(q).then(() => { - location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile"); - }, (e) => { - e.text().then(label => { - location.replace(session.pollenUIContext.uiEndPoint + "/#user/profile?error=" + label); - }); - }); - }; - - if (session.getUser()) { - callback(session.getUser()); - } else { - this.bus.on("user", (user) => { - callback(user); - this.bus.off("user", callback); - }); - } - } - - } else { - this.bus.trigger("pageChanged", "home"); - riot.mount(this.refs.content, "home"); - } - }); - window.onkeydown = e => { if (e.keyCode === 27) { this.bus.trigger("escape"); diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html index 5a0c56d2..78f38e57 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html @@ -10,12 +10,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -25,11 +25,11 @@ require("./popup/FeedbackModal.tag.html"); require("./components/Avatar.tag.html"); <PollenHeader> - <a class="header-home instance-title" href="#home" target="_top"></a> + <a class="header-home instance-title" href="#" target="_top"></a> <div class="header-actions"> - <div> - <a class="header-link header-link--info" href="#/poll/new/text" title="{__.newPoll}"> + <div if={ (session.configurationServer && !session.configurationServer.userConnectedRequired) || user}> + <a class="header-link header-link--info" href="#poll/new/text" title="{__.newPoll}"> <i class="fa fa-plus"></i> <span class="action-label">{__.newPoll}</span> </a> </div> @@ -38,9 +38,9 @@ require("./components/Avatar.tag.html"); <i class="fa fa-wrench"/> </a> <div class="dropdown-content right"> - <a href="#user">{__.users}</a> - <a href="#poll">{__.polls}</a> - <a href="#gtu">{__.gtu}</a> + <a href="#users">{__.users}</a> + <a href="#polls">{__.polls}</a> + <a href="#gtus">{__.gtu}</a> <a href="#loginProviders">{__.loginProviders}</a> </div> </div> @@ -52,9 +52,9 @@ require("./components/Avatar.tag.html"); </a> <div class="dropdown-content right"> <a href="#user/profile">{__.myProfile}</a> - <a href="#poll/created">{__.myPolls}</a> - <a href="#poll/invited">{__.myInvitedPolls}</a> - <a href="#poll/participated">{__.myParticipatedPolls}</a> + <a href="#polls/created">{__.myPolls}</a> + <a href="#polls/invited">{__.myInvitedPolls}</a> + <a href="#polls/participated">{__.myParticipatedPolls}</a> <a href="#favoriteLists">{__.myFavoriteLists}</a> <span role="separator" class="divider"></span> <a onclick="{signOut}">{__.signout}</a> @@ -79,22 +79,23 @@ require("./components/Avatar.tag.html"); </div> <script type="es6"> - let route = require("riot-route"); - let session = require("../js/Session"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; + this.session = require("../js/Session"); - this.installBundle(session, "header"); + this.installBundle(this.session, "header"); this.signIn = () => { this.bus.trigger("signIn"); }; this.signOut = () => { - route("home"); - session.signOut(); + this.session.signOut().then(() => { + route(""); + }); }; - this.user = session.getUser(); + this.user = this.session.getUser(); this.admin = this.user && this.user.administrator; this.onUserChange = user => { diff --git a/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag.html b/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag.html index a9e9c5a4..febf209a 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag.html @@ -10,12 +10,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -53,12 +53,13 @@ <script type="es6"> let authService = require("../js/AuthService"); let session = require("../js/Session"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.installBundle(session, "signcheck"); this.waiting = true; this.error = false; this.succes = false; + authService.validateEmail(this.opts.userId, this.opts.token) .then(() => { this.waiting = false; @@ -72,7 +73,7 @@ }); this.signin = () => { - route("/home"); + route(""); this.bus.trigger("signIn"); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html index 7a873947..f0d4f1c9 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html @@ -10,12 +10,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -77,7 +77,7 @@ require("./components/HumanInput.tag.html"); <script type="es6"> this.session = require("../js/Session"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.installBundle(this.session, "signin"); this.message = ""; @@ -94,7 +94,7 @@ require("./components/HumanInput.tag.html"); this.updateLoginProviders(); }); - this.updateLoginProviders = () => { + this.updateLoginProviders = () => { this.authService.getActiveLoginProviders().then((result) => { this.loginProviders = result; this.update(); @@ -106,15 +106,19 @@ require("./components/HumanInput.tag.html"); }; this.open = () => { - this.openSignIn = true; - this.update(); - this.bus.trigger("signInOpen"); + if (!this.openSignIn) { + this.openSignIn = true; + this.update(); + this.bus.trigger("signInOpen"); + } }; this.close = () => { - this.openSignIn = false; - this.update(); - this.bus.trigger("signInClosed"); + if (this.openSignIn) { + this.openSignIn = false; + this.update(); + this.bus.trigger("signInClosed"); + } }; this.signIn = (e) => { @@ -135,7 +139,7 @@ require("./components/HumanInput.tag.html"); }); }; - this.signinWithProvider = (provider) => (e) => { + this.signinWithProvider = (provider) => () => { let currentPage = location.hash || "#"; localStorage.setItem("currentPage", currentPage); let redirection = encodeURIComponent(this.session.getProviderRedirectionUrl(provider)); @@ -148,6 +152,7 @@ require("./components/HumanInput.tag.html"); <style> .sign-in-layer { + position: absolute; left: 0px; top: 0px; height: 100%; diff --git a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html index 4f37c915..82e52539 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html @@ -10,17 +10,17 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% */ -let route = require("riot-route"); +let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; require("./popup/ResendValidation.tag.html"); require("./components/HumanInput.tag.html"); require("./components/GtuValidation.tag.html"); diff --git a/pollen-ui-riot-js/src/main/web/tag/SigninAction.tag.js b/pollen-ui-riot-js/src/main/web/tag/SigninAction.tag.js new file mode 100644 index 00000000..5dbd80a5 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/SigninAction.tag.js @@ -0,0 +1,27 @@ +let riot = require("riot"); +let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; +let session = require("../js/Session"); + +riot.tag("signinaction", false, function() { + + let q = route.query(); + if (q.loginProvider != null) { + session.signInProvider(q).then(() => { + let currentPage = localStorage.getItem("currentPage"); + localStorage.removeItem("currentPage"); + location.replace(session.pollenUIContext.uiEndPoint + "/" + currentPage); + }, (e) => { + let currentPage = localStorage.getItem("currentPage"); + localStorage.removeItem("currentPage"); + e.text().then(label => { + location.replace(session.pollenUIContext.uiEndPoint + "/" + currentPage + "?error=" + label); + }); + }); + } else { + this.bus.trigger("signIn"); + this.listen("signInClosed", () => { + this.logger.info("route to " + (q.hash || "")); + route(q.hash || ""); + }); + } +}); diff --git a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html index 8852a355..535a02b5 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -213,7 +213,7 @@ require("./components/Avatar.tag.html"); <script type="es6"> this.loaded = false; - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.session = require("../js/Session"); this.installBundle(this.session, "userProfile"); this.errors = {}; @@ -364,7 +364,7 @@ require("./components/Avatar.tag.html"); if (confirm) { userService.deleteUser(this.user.id).then(() => { this.bus.trigger("user", null); - route("home"); + route(""); }); } }); diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html index 32733a09..db6910ff 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -89,7 +89,7 @@ require("../components/LoadingCard.tag.html"); <script type="es6"> let session = require("../../js/Session"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.installBundle(session, "favoriteList"); let favoriteListService = require("../../js/FavoriteListService"); this.pagination = { @@ -158,7 +158,7 @@ require("../components/LoadingCard.tag.html"); label = childrenLabel + membersLabel; } return label; - } + }; this.reloadFavoriteListInfos = () => { favoriteListService.favoriteList(this.favoriteList.id).then(results => { diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListEditModal.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListEditModal.tag.html index 6dcd3dc4..0f228fb8 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListEditModal.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListEditModal.tag.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -40,7 +40,7 @@ require("../popup/Modal.tag.html"); <script type="es6"> let session = require("../../js/Session"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; let Message = require("../../js/Message"); this.installBundle(session, "favoriteList"); let favoriteListService = require("../../js/FavoriteListService"); @@ -71,7 +71,7 @@ require("../popup/Modal.tag.html"); }); } else { promise = favoriteListService.createFavoriteList(favoriteList).then((result) => { - route("/favoriteLists/" + result.id); + route("favoriteLists/" + result.id); }, errors => { this.errors = errors; this.bus.trigger("message", new Message(errors, "error")); diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportCsvModal.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportCsvModal.tag.html index 0b0e14ed..92a41fe8 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportCsvModal.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportCsvModal.tag.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -43,7 +43,7 @@ require("../popup/Modal.tag.html"); <script type="es6"> let session = require("../../js/Session"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.installBundle(session, "favoriteList"); let favoriteListService = require("../../js/FavoriteListService"); diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportLdapModal.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportLdapModal.tag.html index c0932ef2..89cd8618 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportLdapModal.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/ImportLdapModal.tag.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -45,7 +45,7 @@ require("../popup/Modal.tag.html"); <script type="es6"> let session = require("../../js/Session"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.installBundle(session, "favoriteList"); let favoriteListService = require("../../js/FavoriteListService"); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html index def467b5..81e520f1 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html @@ -10,12 +10,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -69,7 +69,7 @@ require("../components/HumanInput.tag.html"); <div class="actions" if={!showSummary}> <a class="c-button c-button--ghost" tabindex="3" - href={form.creation ? "#/home" : ("#/poll/" + form.model.id + "/vote/" + form.model.permission)}> + href={form.creation ? "#home" : ("#poll/" + form.model.id + "/vote/" + form.model.permission)}> <i class="fa fa-undo" aria-hidden="true"></i> {__.cancel} </a> @@ -170,7 +170,7 @@ require("../components/HumanInput.tag.html"); }; if (this.form.creation) { this.form.create().then(() => { - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; route("poll/" + this.form.model.id + "/summary/" + this.form.model.permission); this.bus.trigger("successMessage", this._l("creationSuccess", this.form.model.title)); }, errorFn); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html index d36b97c5..a1b7d006 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html @@ -65,7 +65,7 @@ require("./Report.tag.html"); class="poll-options dropdown"> <a class="header-link"><i class="fa fa-bars"/></a> <div class="dropdown-content"> - <a href="#/poll/{poll.id}/summary/{poll.permission}"> + <a href="#poll/{poll.id}/summary/{poll.permission}"> <i class="link fa fa-pencil-square-o"/> {__.editPoll} </a> @@ -175,7 +175,7 @@ require("./Report.tag.html"); this.poll.init(this.opts.pollId, this.opts.voteId, this.opts.permission).catch((error) => { this.bus.trigger("message", new Message(this._l(error.status), "error")); - route("/"); + route(""); }); this.listen("user", (user, oldUser) => { @@ -196,7 +196,7 @@ require("./Report.tag.html"); this.confirm(this.__.deletePoll).then((confirm) => { if (confirm) { this.poll.delete().then(() => { - route("/home"); + route(""); }); } }); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html index a0ae8716..56890ed8 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html @@ -8,12 +8,12 @@ it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% @@ -149,7 +149,7 @@ require("../components/Search.tag.html"); this.refs.assignModal.refs.pollToAssign.value = ""; this.update(); }, errors => { - this.bus.trigger("message", errors); + this.bus.trigger("message", errors, "error"); this.update(); }); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html index db09c872..2e89f352 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html @@ -130,7 +130,7 @@ require("../components/MultiLineLabel.tag.html"); class="c-button c-button--success"> <i class="link fa fa-play"/> {__.reopenPoll}</a> - <a href="#/poll/{opts.form.model.id}/clone/{opts.form.model.permission}" + <a href="#poll/{opts.form.model.id}/clone/{opts.form.model.permission}" class="c-button c-button--info"> <i class="link fa fa-clone"/> {__.clonePoll} @@ -140,7 +140,7 @@ require("../components/MultiLineLabel.tag.html"); <script type="es6"> this.session = require("../../js/Session"); let Message = require("../../js/Message"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.installBundle(this.session, "summary"); this.showVoteCountingTypeHelper = false; diff --git a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html index fecfd26b..4d5f5754 100644 --- a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html @@ -107,7 +107,7 @@ require("../components/ContextualMenu.tag.html"); this.installBundle(session, "voterList"); let voterListService = require("../../js/VoterListService"); let favoriteListService = require("../../js/FavoriteListService"); - let route = require("riot-route"); + let route = require("riot-route/lib/tag").default; // a voir pourquoi le default doit être mi ; this.user = session.getUser(); this.favoriteLists = []; @@ -172,7 +172,7 @@ require("../components/ContextualMenu.tag.html"); this.exportToFavoriteList = () => { if (session.getUser() && !this.opts.form.currentVoterList.temp) { favoriteListService.importFromVoterList(this.opts.form.currentVoterList.id).then((result) => { - route("/favoriteLists/" + result.id); + route("favoriteLists/" + result.id); }, errors => { this.bus.trigger("message", errors, "error"); this.parent.update(); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.