diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js
index e9341b329b..335bef3415 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js
@@ -79,6 +79,9 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, WhoAmI, Current, $
get manageEvents() {
return getAccess('manage-events');
+ },
+ get impersonation() {
+ return getAccess('impersonation');
}
}
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
index 55f6788ff3..2bb3b29f06 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
@@ -210,7 +210,7 @@ module.controller('UserConsentsCtrl', function($scope, realm, user, userConsents
});
-module.controller('UserListCtrl', function($scope, realm, User) {
+module.controller('UserListCtrl', function($scope, realm, User, UserImpersonation) {
$scope.realm = realm;
$scope.page = 0;
@@ -220,6 +220,16 @@ module.controller('UserListCtrl', function($scope, realm, User) {
first : 0
}
+ $scope.impersonate = function(userId) {
+ UserImpersonation.save({realm : realm.realm, user: userId}, function (data) {
+ if (data.sameRealm) {
+ window.location = data.redirect;
+ } else {
+ window.open(data.redirect, "_blank");
+ }
+ });
+ };
+
$scope.firstPage = function() {
$scope.query.first = 0;
$scope.searchQuery();
@@ -251,7 +261,7 @@ module.controller('UserListCtrl', function($scope, realm, User) {
-module.controller('UserDetailCtrl', function($scope, realm, user, User, UserFederationInstances, RequiredActions, $location, Dialog, Notifications) {
+module.controller('UserDetailCtrl', function($scope, realm, user, User, UserFederationInstances, UserImpersonation, RequiredActions, $location, Dialog, Notifications) {
$scope.realm = realm;
$scope.create = !user.id;
$scope.editUsername = $scope.create || $scope.realm.editUsernameAllowed;
@@ -264,7 +274,17 @@ module.controller('UserDetailCtrl', function($scope, realm, user, User, UserFede
}
convertAttributeValuesToString(user);
+
$scope.user = angular.copy(user);
+ $scope.impersonate = function() {
+ UserImpersonation.save({realm : realm.realm, user: $scope.user.id}, function (data) {
+ if (data.sameRealm) {
+ window.location = data.redirect;
+ } else {
+ window.open(data.redirect, "_blank");
+ }
+ });
+ };
if(user.federationLink) {
console.log("federationLink is not null");
UserFederationInstances.get({realm : realm.realm, instance: user.federationLink}, function(link) {
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js
index 3f79536fde..0398bfa63c 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js
@@ -328,6 +328,13 @@ module.factory('UserConsents', function($resource) {
});
});
+module.factory('UserImpersonation', function($resource) {
+ return $resource(authUrl + '/admin/realms/:realm/users/:user/impersonation', {
+ realm : '@realm',
+ user : '@user'
+ });
+});
+
module.factory('UserCredentials', function($resource) {
var credentials = {};
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/role-mappings.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/role-mappings.html
index 94bf8996ea..898650b70d 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/role-mappings.html
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/role-mappings.html
@@ -8,8 +8,8 @@