use of com.odysseusinc.arachne.portal.exception.UserNotFoundException in project ArachneCentralAPI by OHDSI.
the class BaseUserController method findUserStatus.
@ApiOperation("Get status of registered user")
@GetMapping(value = "/api/v1/auth/status/{userUuid}")
public JsonResult<CommonArachneUserStatusDTO> findUserStatus(@PathVariable("userUuid") String uuid) throws UserNotFoundException {
JsonResult<CommonArachneUserStatusDTO> result;
IUser user = userService.getByUuid(uuid);
if (user == null) {
throw new UserNotFoundException("userUuid", "user not found");
} else {
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(user.getEnabled() ? CommonArachneUserStatusDTO.APPROVED : CommonArachneUserStatusDTO.PENDING);
}
return result;
}
use of com.odysseusinc.arachne.portal.exception.UserNotFoundException in project ArachneCentralAPI by OHDSI.
the class BaseUserController method activate.
@ApiOperation("Register user via activation code.")
@GetMapping(value = "/api/v1/user-management/activation/{activationCode}")
public void activate(Principal principal, HttpServletRequest request, @PathVariable("activationCode") String activateCode, @RequestParam(value = "callbackUrl", required = false) String callbackUrl, HttpServletResponse response) throws IOException, UserNotFoundException, NotExistException, NoSuchFieldException, IllegalAccessException, SolrServerException, URISyntaxException {
getAuthToken(request).forEach(authenticator::invalidateToken);
Boolean activated;
try {
userService.confirmUserEmail(activateCode);
activated = true;
} catch (UserNotFoundException ex) {
activated = false;
}
String safeCallback = callbackUrl != null ? callbackUrl : "/auth/login";
URIBuilder redirectURIBuilder = new URIBuilder(safeCallback);
redirectURIBuilder.addParameter("message", activated ? "email-confirmed" : "email-not-confirmed");
response.sendRedirect(redirectURIBuilder.build().toString());
}
use of com.odysseusinc.arachne.portal.exception.UserNotFoundException in project ArachneCentralAPI by OHDSI.
the class BaseUserServiceImpl method remove.
@Override
@PreAuthorize("hasRole('ROLE_ADMIN')")
@Transactional(rollbackFor = Exception.class)
public void remove(Long id) throws ValidationException, UserNotFoundException, NotExistException, IOException, SolrServerException {
if (id == null) {
throw new ValidationException("remove user: id must be not null");
}
U user = rawUserRepository.findById(id).orElseThrow(() -> new UserNotFoundException("removeUser", "remove user: user not found"));
solrService.delete(user);
rawUserRepository.deleteById(user.getId());
}
Aggregations