コード例 #1
0
 @RequestMapping(method = RequestMethod.POST)
 protected String formSubmit(
     @Valid @ModelAttribute("command") RegistrationForm form,
     BindingResult result,
     HttpServletRequest request)
     throws EuropeanaQueryException { // todo: query exception??
   if (result.hasErrors()) {
     log.info("The registration form has errors");
     clickStreamLogger.logUserAction(request, ClickStreamLogger.UserAction.REGISTER_FAILURE);
     return "register";
   }
   TokenRepo.RegistrationToken token =
       tokenRepo.getRegistrationToken(
           form.getToken()); // the token was validated in handleRequestInternal
   token.delete();
   User user = userRepo.createUser(token.getEmail()); // use email from token. not from form.
   user.setUserName(form.getUserName());
   user.setPassword(form.getPassword());
   user.setEnabled(true);
   user.setRole(User.Role.ROLE_USER);
   user.save();
   sendNotificationEmail(user);
   clickStreamLogger.logUserAction(request, ClickStreamLogger.UserAction.REGISTER_SUCCESS);
   return "register-success";
 }
コード例 #2
0
 @RequestMapping(method = RequestMethod.GET)
 protected String getRequest(
     @RequestParam("token") String tokenKey,
     @ModelAttribute("command") RegistrationForm regForm,
     HttpServletRequest request)
     throws EuropeanaQueryException { // todo: query exception??
   log.info("Received get request, putting token into registration form model attribute");
   TokenRepo.RegistrationToken token = tokenRepo.getRegistrationToken(tokenKey);
   if (token == null) {
     throw new EuropeanaQueryException(
         QueryProblem.TOKEN_EXPIRED
             .toString()); // todo: query exception?? "Registration must be retried, no token for
                           // "+tokenKey
   }
   regForm.setToken(token.getId());
   regForm.setEmail(token.getEmail());
   clickStreamLogger.logUserAction(request, ClickStreamLogger.UserAction.REGISTER);
   return "register";
 }