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