Commit 5e9b1eb6 by Johannes Edmeier

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 #799
parent 15c85206
...@@ -25,6 +25,9 @@ import org.springframework.http.MediaType; ...@@ -25,6 +25,9 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
@AdminController @AdminController
public class UiController { public class UiController {
private final String adminContextPath; private final String adminContextPath;
...@@ -48,8 +51,11 @@ public class UiController { ...@@ -48,8 +51,11 @@ public class UiController {
} }
@ModelAttribute(value = "user", binding = false) @ModelAttribute(value = "user", binding = false)
public Principal getUiSettings(Principal principal) { public Map<String, Object> getUiSettings(Principal principal) {
return principal; if (principal != null) {
return singletonMap("name", principal.getName());
}
return emptyMap();
} }
@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE) @GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment