Пример #1
0
  @RequestMapping(value = "signup", method = RequestMethod.POST)
  public String signup(
      HttpServletRequest request,
      @Valid @ModelAttribute SignupForm signupForm,
      BindingResult result,
      Errors errors,
      RedirectAttributes ra) {
    convertPasswordError(result);
    if (!errors.hasErrors()) {
      validateUniqueEmail(signupForm.getEmail(), errors);
    }

    if (errors.hasErrors()) {
      LOG.info("Errors in signup form");
      return SIGNUP_VIEW_NAME;
    }

    signUpService.signup(
        request,
        signupForm.getFirstName(),
        signupForm.getSurname(),
        signupForm.getEmail(),
        signupForm.getPassword());
    // see /WEB-INF/i18n/messages.properties and /WEB-INF/views/homeSignedIn.html
    MessageHelper.addInfoAttribute(ra, "signup.success");
    return "redirect:/signin";
  }
Пример #2
0
 @RequestMapping(value = "activate")
 public String activate(@RequestParam Long id, @RequestParam String key, RedirectAttributes ra) {
   LOG.info("New activation detected for id {} with key {}", id, key);
   if (signUpService.activate(id, key)) {
     MessageHelper.addInfoAttribute(ra, "activation.success");
   }
   return "redirect:/signin";
 }
  @Scheduled(fixedRate = 300000) // every 5 minutes
  public void scavengeUnusedPasswordResetRequests() {
    LOG.info("Scavenging password resets...");

    try {
      signUpService.removeExpiredPasswordResets();
    } catch (Throwable t) {
      LOG.error("Exception caught removing expired passwords", t);
    }
  }