small fixes
This commit is contained in:
parent
b6f5e73401
commit
f6447e7094
@ -33,7 +33,7 @@ public class UserDto {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
public void setEmail(final String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class UserDto {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Integer role) {
|
||||
public void setRole(final Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class UserDto {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
public void setFirstName(final String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public class UserDto {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
public void setLastName(final String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public class UserDto {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ public class UserDto {
|
||||
return matchingPassword;
|
||||
}
|
||||
|
||||
public void setMatchingPassword(String matchingPassword) {
|
||||
public void setMatchingPassword(final String matchingPassword) {
|
||||
this.matchingPassword = matchingPassword;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -102,25 +101,22 @@ public class OldRegistrationController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/user/registration", method = RequestMethod.POST)
|
||||
public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid final UserDto accountDto, final BindingResult result, final HttpServletRequest request, final Errors errors) {
|
||||
LOGGER.debug("Registering user account with information: {}", accountDto);
|
||||
if (result.hasErrors()) {
|
||||
return new ModelAndView("registration", "user", accountDto);
|
||||
}
|
||||
public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid final UserDto userDto, final HttpServletRequest request, final Errors errors) {
|
||||
LOGGER.debug("Registering user account with information: {}", userDto);
|
||||
|
||||
final User registered = createUserAccount(accountDto);
|
||||
final User registered = createUserAccount(userDto);
|
||||
if (registered == null) {
|
||||
result.rejectValue("email", "message.regError");
|
||||
return new ModelAndView("registration", "user", accountDto);
|
||||
// result.rejectValue("email", "message.regError");
|
||||
return new ModelAndView("registration", "user", userDto);
|
||||
}
|
||||
try {
|
||||
final String appUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
eventPublisher.publishEvent(new OnRegistrationCompleteEvent(registered, request.getLocale(), appUrl));
|
||||
} catch (final Exception ex) {
|
||||
LOGGER.warn("Unable to register user", ex);
|
||||
return new ModelAndView("emailError", "user", accountDto);
|
||||
return new ModelAndView("emailError", "user", userDto);
|
||||
}
|
||||
return new ModelAndView("successRegister", "user", accountDto);
|
||||
return new ModelAndView("successRegister", "user", userDto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/user/resendRegistrationToken", method = RequestMethod.GET)
|
||||
|
@ -28,9 +28,9 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH
|
||||
|
||||
// 400
|
||||
@Override
|
||||
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
|
||||
protected ResponseEntity<Object> handleMethodArgumentNotValid(final MethodArgumentNotValidException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) {
|
||||
logger.error("400 Status Code", ex);
|
||||
BindingResult result = ex.getBindingResult();
|
||||
final BindingResult result = ex.getBindingResult();
|
||||
final GenericResponse bodyOfResponse = new GenericResponse(result.getFieldErrors(), result.getGlobalErrors());
|
||||
return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request);
|
||||
}
|
||||
@ -48,14 +48,14 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH
|
||||
public ResponseEntity<Object> handleMail(final RuntimeException ex, final WebRequest request) {
|
||||
logger.error("500 Status Code", ex);
|
||||
final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.email.config.error", null, request.getLocale()), "MailError");
|
||||
return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request);
|
||||
return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
|
||||
}
|
||||
|
||||
@ExceptionHandler({ Exception.class })
|
||||
public ResponseEntity<Object> handleInternal(final RuntimeException ex, final WebRequest request) {
|
||||
logger.error("500 Status Code", ex);
|
||||
final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.error", null, request.getLocale()), "InternalError");
|
||||
return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request);
|
||||
return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user