bael-5249: add User ID

This commit is contained in:
sharifi 2022-05-03 17:55:30 +04:30
parent da3f8ad4a0
commit b9da120df0
1 changed files with 7 additions and 0 deletions

View File

@ -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";
} }