diff --git a/backend/src/main/java/com/alttd/altitudeweb/controllers/login/LoginController.java b/backend/src/main/java/com/alttd/altitudeweb/controllers/login/LoginController.java index a8c666d..71b36ee 100644 --- a/backend/src/main/java/com/alttd/altitudeweb/controllers/login/LoginController.java +++ b/backend/src/main/java/com/alttd/altitudeweb/controllers/login/LoginController.java @@ -96,16 +96,15 @@ public class LoginController implements LoginApi { log.debug("Loading username for logged in user"); Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); log.debug("Loaded authentication for logged in user {}", authentication); - if (authentication == null || !(authentication.getPrincipal() instanceof OAuth2ResourceServerProperties.Jwt)) { + if (authentication == null || !(authentication.getPrincipal() instanceof Jwt jwt)) { log.debug("Loaded authentication for logged in user is null or not a jwt"); return ResponseEntity.status(401).build(); } - Jwt jwt = (Jwt) authentication.getPrincipal(); String stringUuid = jwt.getSubject(); UUID uuid; try { - uuid = UUID.fromString(stringUuid); - log.debug("Loaded username for logged in user {}", uuid); + uuid = UUID.fromString(stringUuid); + log.debug("Loaded username for logged in user {}", uuid); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().build(); }