Skip to content

Commit a08a97f

Browse files
committed
👌 FB CR: add email-claim null check
1 parent 5ab7573 commit a08a97f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

personalization-service/src/main/java/de/muenchen/dbs/personalization/checklist/ChecklistService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ private Checklist getChecklistOrThrowException(final UUID checklistId) {
7979
private String getUserMailFromAuthenticationOrThrow() {
8080
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
8181
if (authentication.getPrincipal() instanceof Jwt jwt) {
82-
final String email = jwt.getClaims().get("email").toString();
83-
if (!StringUtils.isBlank(email)) {
84-
return email;
82+
Object emailClaim = jwt.getClaims().get("email");
83+
if(emailClaim != null) {
84+
final String email = emailClaim.toString();
85+
if (!StringUtils.isBlank(email)) {
86+
return email;
87+
}
8588
}
8689
}
8790
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED);

0 commit comments

Comments
 (0)