From ae242f84804b3dfb2c898fef29dc7ceb7daff0da Mon Sep 17 00:00:00 2001 From: "nick.grange" Date: Sat, 4 Jul 2015 22:38:34 +1000 Subject: [PATCH] KEYCLOAK-1486 fixed User link in Clients' Active Sessions page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed User link in Clients' Active Sessions page to use userId instead of username to show User details instead of Resource not found. Renamed UserSessionRepresentation’s user attribute to username as it was ambiguous and only used in 1 place (i.e. client-sessions.html). --- .../idm/UserSessionRepresentation.java | 19 ++++++++++++++----- .../resources/partials/client-sessions.html | 2 +- .../models/utils/ModelToRepresentation.java | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/keycloak/representations/idm/UserSessionRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/UserSessionRepresentation.java index 6701f6acfa..bcb363b8ea 100755 --- a/core/src/main/java/org/keycloak/representations/idm/UserSessionRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/UserSessionRepresentation.java @@ -11,7 +11,8 @@ import java.util.Set; */ public class UserSessionRepresentation { private String id; - private String user; + private String username; + private String userId; private String ipAddress; private long start; private long lastAccess; @@ -25,12 +26,20 @@ public class UserSessionRepresentation { this.id = id; } - public String getUser() { - return user; + public String getUsername() { + return username; } - public void setUser(String user) { - this.user = user; + public void setUsername(String username) { + this.username = username; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; } public String getIpAddress() { diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/client-sessions.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/client-sessions.html index 838b166d55..2b445e149d 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/client-sessions.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/client-sessions.html @@ -48,7 +48,7 @@ - {{session.user}} + {{session.username}} {{session.ipAddress}} {{session.start | date:'medium'}} diff --git a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java index 7039262350..27a05396ff 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java +++ b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java @@ -230,7 +230,8 @@ public class ModelToRepresentation { rep.setId(session.getId()); rep.setStart(Time.toMillis(session.getStarted())); rep.setLastAccess(Time.toMillis(session.getLastSessionRefresh())); - rep.setUser(session.getUser().getUsername()); + rep.setUsername(session.getUser().getUsername()); + rep.setUserId(session.getUser().getId()); rep.setIpAddress(session.getIpAddress()); for (ClientSessionModel clientSession : session.getClientSessions()) { ClientModel client = clientSession.getClient();