@Test public void testConfirmRegistration() { ResponseEntity<UserRegistrationApiData> registrationResponse = executeTestRegistration(); UserRegistrationsResource.UserRegistrationSearchResultResource registrationSearchResultResource = service() .userRegistrations() .findByToken(registrationResponse.getBody().getRegistrationConfirmationToken()); assertThat(registrationSearchResultResource.exists(), is(true)); ResponseEntity confirmationResponse = registrationSearchResultResource.confirmRegistration(); assertThat(confirmationResponse.getStatusCode(), is(HttpStatus.OK)); Optional<UserApiData> registeredUserOptional = service().users().search().findByUsername("test").getData().stream().findFirst(); assertThat(registeredUserOptional.isPresent(), is(true)); UserApiData registeredUser = registeredUserOptional.get(); assertThat(registeredUser.getRegistrationConfirmationToken(), is(nullValue())); assertThat(registeredUser.isEnabled(), is(true)); }
@RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) public ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken) { User user = userService.findByRegistrationConfirmationToken(registrationConfirmationToken); if (user == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } user.clearRegistrationConfirmationToken(); user.setEnabled(true); userService.save(user); return new ResponseEntity(HttpStatus.OK); }
UserRegistrationRestController implements ResourceProcessor<RepositoryLinksResource> { @RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) public ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken) { User user = userService.findByRegistrationConfirmationToken(registrationConfirmationToken); if (user == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } user.clearRegistrationConfirmationToken(); user.setEnabled(true); userService.save(user); return new ResponseEntity(HttpStatus.OK); } }
UserRegistrationRestController implements ResourceProcessor<RepositoryLinksResource> { @RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) public ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken) { User user = userService.findByRegistrationConfirmationToken(registrationConfirmationToken); if (user == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } user.clearRegistrationConfirmationToken(); user.setEnabled(true); userService.save(user); return new ResponseEntity(HttpStatus.OK); }  }
UserRegistrationRestController implements ResourceProcessor<RepositoryLinksResource> { @RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) public ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken) { User user = userService.findByRegistrationConfirmationToken(registrationConfirmationToken); if (user == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } user.clearRegistrationConfirmationToken(); user.setEnabled(true); userService.save(user); return new ResponseEntity(HttpStatus.OK); }  @RequestMapping(RestApiConstants.SEARCH_RESOURCE) ResponseEntity<UserRegistrationResource> searchRegistration(@RequestParam String token); @RequestMapping(method = RequestMethod.GET) RegistrationsResource getResource(); @RequestMapping(method = RequestMethod.POST) ResponseEntity<UserRegistrationResource> registerUser(@RequestBody UserRegistrationApiData
                                                                             userRegistration); @RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken); @Override RepositoryLinksResource process(RepositoryLinksResource resource); }
UserRegistrationRestController implements ResourceProcessor<RepositoryLinksResource> { @RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) public ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken) { User user = userService.findByRegistrationConfirmationToken(registrationConfirmationToken); if (user == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } user.clearRegistrationConfirmationToken(); user.setEnabled(true); userService.save(user); return new ResponseEntity(HttpStatus.OK); }  @RequestMapping(RestApiConstants.SEARCH_RESOURCE) ResponseEntity<UserRegistrationResource> searchRegistration(@RequestParam String token); @RequestMapping(method = RequestMethod.GET) RegistrationsResource getResource(); @RequestMapping(method = RequestMethod.POST) ResponseEntity<UserRegistrationResource> registerUser(@RequestBody UserRegistrationApiData
                                                                             userRegistration); @RequestMapping(value = "{token}/confirm", method = RequestMethod.POST) ResponseEntity confirmRegistration(@PathVariable("token") String registrationConfirmationToken); @Override RepositoryLinksResource process(RepositoryLinksResource resource);  }