@Test public void testVerifyLink() throws Exception { when( accountVerificationService .isAccountVerificationTokenExpired(anyString())) .thenReturn(true); mockMvc.perform( get("/verifyLink.html?token=914653028441015461098868301011413486798")) .andExpect(status().isOk()) .andExpect(view().name("views/signupVerification")); when( accountVerificationService .isAccountVerificationTokenExpired(anyString())) .thenReturn(false); mockMvc.perform( get("/verifyLink.html?token=914653028441015461098868301011413486798")) .andExpect(redirectedUrl("/index.html")); }
@RequestMapping(value = "verifyLink.html") public String verifyLink( @RequestParam(value = "token", required = true) String token, Model model, HttpServletRequest request) throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { try { if (accountVerificationService .isAccountVerificationTokenExpired(token)) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } } catch (TokenNotExistException ex) { model.addAttribute("tokenNotExist", true); return "views/signupVerification"; } String linkUrl = getServletUrl(request); AccountVerificationDto accountVerificationDto = new AccountVerificationDto( token); try { accountVerificationService.enableAccount(accountVerificationDto, linkUrl); } catch (TokenExpiredException ex) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } return "redirect:/index.html"; }
SignupController extends AbstractController { @RequestMapping(value = "verifyLink.html") public String verifyLink( @RequestParam(value = "token", required = true) String token, Model model, HttpServletRequest request) throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { try { if (accountVerificationService .isAccountVerificationTokenExpired(token)) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } } catch (TokenNotExistException ex) { model.addAttribute("tokenNotExist", true); return "views/signupVerification"; } String linkUrl = getServletUrl(request); AccountVerificationDto accountVerificationDto = new AccountVerificationDto( token); try { accountVerificationService.enableAccount(accountVerificationDto, linkUrl); } catch (TokenExpiredException ex) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } return "redirect:/index.html"; } }
SignupController extends AbstractController { @RequestMapping(value = "verifyLink.html") public String verifyLink( @RequestParam(value = "token", required = true) String token, Model model, HttpServletRequest request) throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { try { if (accountVerificationService .isAccountVerificationTokenExpired(token)) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } } catch (TokenNotExistException ex) { model.addAttribute("tokenNotExist", true); return "views/signupVerification"; } String linkUrl = getServletUrl(request); AccountVerificationDto accountVerificationDto = new AccountVerificationDto( token); try { accountVerificationService.enableAccount(accountVerificationDto, linkUrl); } catch (TokenExpiredException ex) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } return "redirect:/index.html"; } @Autowired  SignupController(AccountService accountService,
			AdministrativeGenderCodeService administrativeGenderCodeService,
			FieldValidator fieldValidator,
			AccountVerificationService accountVerificationService,
			RecaptchaService recaptchaUtil, EventService eventService); }
SignupController extends AbstractController { @RequestMapping(value = "verifyLink.html") public String verifyLink( @RequestParam(value = "token", required = true) String token, Model model, HttpServletRequest request) throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { try { if (accountVerificationService .isAccountVerificationTokenExpired(token)) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } } catch (TokenNotExistException ex) { model.addAttribute("tokenNotExist", true); return "views/signupVerification"; } String linkUrl = getServletUrl(request); AccountVerificationDto accountVerificationDto = new AccountVerificationDto( token); try { accountVerificationService.enableAccount(accountVerificationDto, linkUrl); } catch (TokenExpiredException ex) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } return "redirect:/index.html"; } @Autowired  SignupController(AccountService accountService,
			AdministrativeGenderCodeService administrativeGenderCodeService,
			FieldValidator fieldValidator,
			AccountVerificationService accountVerificationService,
			RecaptchaService recaptchaUtil, EventService eventService); @RequestMapping(value = "registration.html") String signup(
			Model model,
			@RequestParam(value = "notify", required = false) String notification); @RequestMapping(value = "registration.html", method = RequestMethod.POST) String signup(@Valid SignupDto signupDto, BindingResult result,
			HttpServletRequest request, RedirectAttributes redirectAttributes,
			Model model); @RequestMapping(value = "verifyLink.html") String verifyLink(
			@RequestParam(value = "token", required = true) String token,
			Model model, HttpServletRequest request); }
SignupController extends AbstractController { @RequestMapping(value = "verifyLink.html") public String verifyLink( @RequestParam(value = "token", required = true) String token, Model model, HttpServletRequest request) throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { try { if (accountVerificationService .isAccountVerificationTokenExpired(token)) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } } catch (TokenNotExistException ex) { model.addAttribute("tokenNotExist", true); return "views/signupVerification"; } String linkUrl = getServletUrl(request); AccountVerificationDto accountVerificationDto = new AccountVerificationDto( token); try { accountVerificationService.enableAccount(accountVerificationDto, linkUrl); } catch (TokenExpiredException ex) { model.addAttribute("tokenExpired", true); return "views/signupVerification"; } return "redirect:/index.html"; } @Autowired  SignupController(AccountService accountService,
			AdministrativeGenderCodeService administrativeGenderCodeService,
			FieldValidator fieldValidator,
			AccountVerificationService accountVerificationService,
			RecaptchaService recaptchaUtil, EventService eventService); @RequestMapping(value = "registration.html") String signup(
			Model model,
			@RequestParam(value = "notify", required = false) String notification); @RequestMapping(value = "registration.html", method = RequestMethod.POST) String signup(@Valid SignupDto signupDto, BindingResult result,
			HttpServletRequest request, RedirectAttributes redirectAttributes,
			Model model); @RequestMapping(value = "verifyLink.html") String verifyLink(
			@RequestParam(value = "token", required = true) String token,
			Model model, HttpServletRequest request);  }