String authHeader = request.getHeader(AuthUtils.AUTH_HEADER_KEY);
if (StringUtils.isNotBlank(authHeader)) {
if (user.isPresent()) {
return Response
.status(Status.CONFLICT)
.entity(new ErrorMessage(String.format(CONFLICT_MSG, provider.capitalize())))
.build();
}
String subject = AuthUtils.getSubject(authHeader);
Optional<User> foundUser = dao.findById(Long.parseLong(subject));
if (!foundUser.isPresent()) {
return Response.status(Status.NOT_FOUND).entity(new ErrorMessage(NOT_FOUND_MSG))
.build();
}
userToSave = foundUser.get();
userToSave.setProviderId(provider, id);