bael-5249: add User ID
@@ -24,6 +24,8 @@ public class CustomUserAttrController {
final Principal principal = (Principal) authentication.getPrincipal();
String dob = "";
+ String userIdByToken = "";
+ String userIdByMapper = "";
if (principal instanceof KeycloakPrincipal) {
@@ -31,6 +33,9 @@ public class CustomUserAttrController {
IDToken token = kPrincipal.getKeycloakSecurityContext()
.getIdToken();
+ userIdByToken = token.getSubject();
+ userIdByMapper = token.getOtherClaims().get("user_id").toString();
+
Map<String, Object> customClaims = token.getOtherClaims();
if (customClaims.containsKey("DOB")) {
@@ -39,6 +44,8 @@ public class CustomUserAttrController {
}
model.addAttribute("username", principal.getName());
+ model.addAttribute("userIDByToken", userIdByToken);
+ model.addAttribute("userIDByMapper", userIdByMapper);
model.addAttribute("dob", dob);
return "userInfo";
}
