Skip to content

Commit 5e9b1eb

Browse files
committed
Don't json serialize the principal
Since the principal not necessarily is json-searializable we need to avoid this and just pass the wanted properties to thymeleaf fixes codecentric#799
1 parent 15c8520 commit 5e9b1eb

File tree

1 file changed

+8
-2
lines changed
  • spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/web

1 file changed

+8
-2
lines changed

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/web/UiController.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.springframework.web.bind.annotation.GetMapping;
2626
import org.springframework.web.bind.annotation.ModelAttribute;
2727

28+
import static java.util.Collections.emptyMap;
29+
import static java.util.Collections.singletonMap;
30+
2831
@AdminController
2932
public class UiController {
3033
private final String adminContextPath;
@@ -48,8 +51,11 @@ public Map<String, Object> getUiSettings() {
4851
}
4952

5053
@ModelAttribute(value = "user", binding = false)
51-
public Principal getUiSettings(Principal principal) {
52-
return principal;
54+
public Map<String, Object> getUiSettings(Principal principal) {
55+
if (principal != null) {
56+
return singletonMap("name", principal.getName());
57+
}
58+
return emptyMap();
5359
}
5460

5561
@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)

0 commit comments

Comments
 (0)