Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
feat(user): return 404 when user when user doesn't have avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
gcusnieux committed Nov 27, 2019
1 parent 7932c9d commit 8861a99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ protected Response createListResponse(List dataList, PaginationParam paginationP
}

protected Response createPictureReponse(Request request, InlinePictureEntity image) {
if (image == null || image.getContent() == null) {
return Response.status(Status.NOT_FOUND).build();
}
CacheControl cc = new CacheControl();
cc.setNoTransform(true);
cc.setMustRevalidate(false);
Expand Down Expand Up @@ -418,4 +421,4 @@ public int hashCode() {
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ public class UserServiceImpl extends AbstractService implements UserService {
private GenericNotificationConfigService genericNotificationConfigService;
@Autowired
private GroupService groupService;

@Value("${user.avatar:${gravitee.home}/assets/default_user_avatar.png}")
private String defaultAvatar;

@Value("${user.login.defaultApplication:true}")
private boolean defaultApplicationForFirstConnection;

Expand Down Expand Up @@ -390,14 +388,9 @@ public PictureEntity getPicture(String id) {
}
}

// Return default inline user avatar
// Return empty image
InlinePictureEntity imageEntity = new InlinePictureEntity();
imageEntity.setType("image/png");
try {
imageEntity.setContent(IOUtils.toByteArray(new FileInputStream(defaultAvatar)));
} catch (IOException ioe) {
LOGGER.error("Default icon for API does not exist", ioe);
}
return imageEntity;
}

Expand Down

0 comments on commit 8861a99

Please sign in to comment.