Search in sources :

Example 1 with ArachnePasswordInfoDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.ArachnePasswordInfoDTO in project ArachneCentralAPI by OHDSI.

the class ExceptionHandlingController method exceptionHandler.

@ExceptionHandler(PasswordValidationException.class)
public ResponseEntity<JsonResult> exceptionHandler(PasswordValidationException ex) {
    LOGGER.error("User tried to register with weak password");
    JsonResult result = new JsonResult<>(VALIDATION_ERROR);
    result.setErrorMessage("You have provided a weak password");
    final ArachnePasswordInfoDTO passwordInfoDTO = conversionService.convert(ex.getPasswordInfo(), ArachnePasswordInfoDTO.class);
    result.getValidatorErrors().put("password", passwordInfoDTO);
    return new ResponseEntity<>(result, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ArachnePasswordInfoDTO(com.odysseusinc.arachne.commons.api.v1.dto.ArachnePasswordInfoDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Aggregations

ArachnePasswordInfoDTO (com.odysseusinc.arachne.commons.api.v1.dto.ArachnePasswordInfoDTO)1 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 ResponseEntity (org.springframework.http.ResponseEntity)1 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1