diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java index 2af6c8a5..bfd0b13c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java @@ -42,7 +42,7 @@ public class LoginController { result = new ModelAndView("forward:/c/maps/"); } else { result = new ModelAndView("login"); - result.addObject("isHsql", driver.indexOf("hsql") != -1); + result.addObject("isHsql", driver.contains("hsql")); } return result; } diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java index 9f2d76d0..ce7e0ca4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java @@ -19,11 +19,19 @@ package com.wisemapping.ncontroller; +import com.wisemapping.controller.Messages; +import com.wisemapping.exceptions.WiseMappingException; +import com.wisemapping.model.User; import com.wisemapping.service.InvalidUserEmailException; import com.wisemapping.service.UserService; +import com.wisemapping.validator.UserValidator; +import com.wisemapping.view.UserBean; +import net.tanesha.recaptcha.ReCaptcha; +import net.tanesha.recaptcha.ReCaptchaResponse; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.ModelAttribute; @@ -32,6 +40,9 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; +import javax.servlet.http.HttpServletRequest; +import java.util.Properties; + @Controller public class UsersController { @@ -39,6 +50,16 @@ public class UsersController { @Autowired private UserService userService; + @Value("${registration.email.enabled}") + boolean emailConfirmEnabled; + + @Autowired + private ReCaptcha captchaService; + + @Value("${registration.recaptcha.enabled}") + private boolean captchaEnabled; + + @RequestMapping(value = "user/resetPassword", method = RequestMethod.GET) public ModelAndView showResetPasswordPage() { return new ModelAndView("forgotPassword"); @@ -59,7 +80,62 @@ public class UsersController { return result; } - public void setUserService(@NotNull UserService userService) { - this.userService = userService; + @RequestMapping(value = "user/registration", method = RequestMethod.GET) + public ModelAndView showRegistrationPage(@NotNull HttpServletRequest request) { + if (captchaEnabled) { + // If captcha is enabled, generate it ... + final Properties prop = new Properties(); + prop.put("theme", "white"); + + final String captchaHtml = captchaService.createRecaptchaHtml(null, prop); + request.setAttribute("captchaHtml", captchaHtml); + request.setAttribute("captchaEnabled", true); + } + return new ModelAndView("userRegistration", "user", new UserBean()); + } + + @RequestMapping(value = "user/registration", method = RequestMethod.POST) + public ModelAndView registerUser(@ModelAttribute("user") UserBean userBean, @NotNull HttpServletRequest request, @NotNull BindingResult bindingResult) throws WiseMappingException { + ModelAndView result; + validateRegistrationForm(userBean, request, bindingResult); + if (bindingResult.hasErrors()) { + result = this.showRegistrationPage(request); + result.addObject("user", userBean); + } else { + final User user = new User(); + + // trim() the email email in order to remove spaces ... + user.setEmail(userBean.getEmail().trim()); + user.setUsername(userBean.getUsername()); + user.setFirstname(userBean.getFirstname()); + user.setLastname(userBean.getLastname()); + user.setPassword(userBean.getPassword()); + userService.createUser(user, emailConfirmEnabled); + + // Forward to the success view ... + result = new ModelAndView("userRegistrationSuccess"); + result.addObject("confirmByEmail", emailConfirmEnabled); + } + return result; + } + + private BindingResult validateRegistrationForm(@NotNull UserBean userBean, @NotNull HttpServletRequest request, @NotNull BindingResult bindingResult) { + final UserValidator userValidator = new UserValidator(); + userValidator.setUserService(userService); + userValidator.setCaptchaService(captchaService); + userValidator.validate(userBean, bindingResult); + + // If captcha is enabled, generate it ... + if (captchaEnabled) { + final String challenge = request.getParameter("recaptcha_challenge_field"); + final String uresponse = request.getParameter("recaptcha_response_field"); + + final String remoteAddr = request.getRemoteAddr(); + final ReCaptchaResponse reCaptchaResponse = captchaService.checkAnswer(remoteAddr, challenge, uresponse); + if (!reCaptchaResponse.isValid()) { + bindingResult.rejectValue("captcha", Messages.CAPTCHA_ERROR); + } + } + return bindingResult; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java b/wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java similarity index 87% rename from wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java rename to wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java index 793db3a6..2945702c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java @@ -22,20 +22,20 @@ import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.Collaborator; import com.wisemapping.model.User; -public class ColaboratorBean +public class CollaboratorBean { private CollaborationRole collaborationRole; private boolean isUser; private Collaborator collaborator; - public ColaboratorBean(Collaborator collaborator, CollaborationRole role) + public CollaboratorBean(Collaborator collaborator, CollaborationRole role) { this.collaborator = collaborator; this.collaborationRole = role; this.isUser = false; } - public ColaboratorBean(User user, CollaborationRole role) + public CollaboratorBean(User user, CollaborationRole role) { this.collaborator = user; this.collaborationRole = role; diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index 5711f5c9..f6c24ae1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -29,8 +29,8 @@ import java.util.*; public class MindMapBean { private MindMap mindMap; - private List viewers; - private List colaborators; + private List viewers; + private List colaborators; public MindMapBean(final MindMap mindmap) { this.mindMap = mindmap; @@ -62,11 +62,11 @@ public class MindMapBean { return mindMap.isStarred(Utils.getUser()); } - public List getViewers() { + public List getViewers() { return viewers; } - public List getCollaborators() { + public List getCollaborators() { return colaborators; } @@ -86,12 +86,12 @@ public class MindMapBean { return mindMap.getTags(); } - private List getColaboratorBy(Set source, CollaborationRole role) { - List col = new ArrayList(); + private List getColaboratorBy(Set source, CollaborationRole role) { + List col = new ArrayList(); if (source != null) { for (Collaboration mu : source) { if (mu.getRole() == role) { - col.add(new ColaboratorBean(mu.getCollaborator(), mu.getRole())); + col.add(new CollaboratorBean(mu.getCollaborator(), mu.getRole())); } } } diff --git a/wise-webapp/src/main/webapp/WEB-INF/app.properties b/wise-webapp/src/main/webapp/WEB-INF/app.properties index 10477130..2769d606 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/app.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/app.properties @@ -58,12 +58,12 @@ mail.supportEmail=root@localhost registration.email.enabled = false # Enable captcha confirmation -registration.recaptcha.enabled = false +registration.recaptcha.enabled = true # ReCaptcha is the default captcha. Public and private keys are required. -# More Info: http://www.google.com/recaptcha -registration.recaptcha.privateKey = -registration.recaptcha.publicKey = +# More Info: http://www.google.com/recaptcha . +registration.recaptcha.privateKey = 6LeQ4tISAAAAAMfHMPRKyHupTfA-KE4QeTCnLXhK +registration.recaptcha.publicKey = 6LeQ4tISAAAAALzCGKNgRv8UqsDx7Cb0vq4wbJBr ################################################################################## # Site configuration diff --git a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml index 1cd30f49..a2f617a1 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml @@ -77,9 +77,9 @@ - + - + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml index 1706ec48..7d75d883 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml @@ -74,7 +74,7 @@ /index.jsp /c/home /c/login - /c/userRegistration + /c/user/registration /c/captcha /c/publicView /service/* diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml index a0fa10bf..32e0262a 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml @@ -23,7 +23,7 @@ - + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 5871a7b3..57671a0c 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -3,24 +3,6 @@ - - - - - - - - - - - - - - - - - - @@ -61,24 +43,4 @@ - - - - - - - - - - - - usersController - loginController - activationController - changePasswordController - settingsController - editProfileController - - - - \ No newline at end of file +ans> \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/js/mymaps.js b/wise-webapp/src/main/webapp/js/mymaps.js index 2fb04cc3..822ede78 100644 --- a/wise-webapp/src/main/webapp/js/mymaps.js +++ b/wise-webapp/src/main/webapp/js/mymaps.js @@ -196,7 +196,7 @@ function updateStatusToolbar() { // Can be executed by the owner ? var rowData = tableElem.dataTable().fnGetData(selectedRows[0]); if (rowData.role != 'owner') { - $("#buttonsToolbar").find('#publishBtn').hide().end().find('#shareBtn').hide(); + $("#buttonsToolbar").find('#publishBtn').hide().end().find('#shareBtn').hide().end().find('#renameBtn').hide(); } } else { $("#buttonsToolbar .act-multiple").show(); diff --git a/wise-webapp/src/main/webapp/jsp/login.jsp b/wise-webapp/src/main/webapp/jsp/login.jsp index c8a50ecc..f1d7da4f 100644 --- a/wise-webapp/src/main/webapp/jsp/login.jsp +++ b/wise-webapp/src/main/webapp/jsp/login.jsp @@ -62,7 +62,7 @@ diff --git a/wise-webapp/src/main/webapp/jsp/userForgotPassword.jsp b/wise-webapp/src/main/webapp/jsp/userForgotPassword.jsp index e8587561..1f70f92d 100755 --- a/wise-webapp/src/main/webapp/jsp/userForgotPassword.jsp +++ b/wise-webapp/src/main/webapp/jsp/userForgotPassword.jsp @@ -33,7 +33,7 @@ - + \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/jsp/userRegistration.jsp b/wise-webapp/src/main/webapp/jsp/userRegistration.jsp index d73f0ffe..00f2ea0a 100644 --- a/wise-webapp/src/main/webapp/jsp/userRegistration.jsp +++ b/wise-webapp/src/main/webapp/jsp/userRegistration.jsp @@ -1,6 +1,4 @@ <%@ include file="/jsp/init.jsp" %> - -
@@ -35,23 +33,28 @@ - ${requestScope.captchaHtml} +

+ +

+ code="HERE"/>.

- " id="submitButton" + " + data-loading-text=" ..." id="submitButton" class="btn btn-primary"> " onclick="window.location='c/'" class="btn">
+ + diff --git a/wise-webapp/src/main/webapp/jsp/userRegistrationSuccess.jsp b/wise-webapp/src/main/webapp/jsp/userRegistrationSuccess.jsp index 811defee..d121251c 100644 --- a/wise-webapp/src/main/webapp/jsp/userRegistrationSuccess.jsp +++ b/wise-webapp/src/main/webapp/jsp/userRegistrationSuccess.jsp @@ -1,30 +1,29 @@ <%@ include file="/jsp/init.jsp" %>
-

- -

- -

Thanks for signing up!

- You will receive a confirmation message shortly from WiseMapping. This message will ask you to activate your WiseMapping account. + You will receive a confirmation message shortly from WiseMapping. This message will ask you to activate your + WiseMapping account. Please select the link to activate and start creating and sharing maps.


+

Thanks so much for your interest in WiseMapping.


+

If you have any questions or have any feedback, please don't hesitate to use the on line form. We'd love to hear from you.

- +

- Your account has been created successfully, click here to sign in and start enjoying WiseMapping. + Your account has been created successfully, click here to sign in and start enjoying + WiseMapping.