impersonation redo in admin console
This commit is contained in:
1 parent
ef255c6a5c
commit
608701aea7
17 files changed
+114
-278
No files matched your search
+3
@@ -79,6 +79,9 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, WhoAmI, Current, $
|
||||
|
||||
get manageEvents() {
|
||||
return getAccess('manage-events');
|
||||
},
|
||||
get impersonation() {
|
||||
return getAccess('impersonation');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-2
@@ -154,7 +154,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;
|
||||
|
||||
@@ -164,6 +164,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();
|
||||
@@ -195,7 +205,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;
|
||||
@@ -208,7 +218,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) {
|
||||
|
||||
@@ -319,6 +319,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 = {};
|
||||
|
||||
|
||||
+5
-4
@@ -116,13 +116,14 @@
|
||||
<button kc-cancel data-ng-click="cancel()">Cancel</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageUsers">
|
||||
<button kc-save data-ng-show="changed">Save</button>
|
||||
<button kc-reset data-ng-show="changed">Cancel</button>
|
||||
<div class="col-md-10 col-md-offset-2" data-ng-show="!create">
|
||||
<button kc-save data-ng-show="access.manageUsers && changed">Save</button>
|
||||
<button kc-reset data-ng-show="access.manageUsers && changed">Cancel</button>
|
||||
<button data-ng-show="access.impersonation" class="btn btn-default" data-ng-click="impersonate()">Impersonate</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<kc-menu></kc-menu>
|
||||
<kc-menu></kc-menu>
|
||||
+4
-2
@@ -5,7 +5,7 @@
|
||||
<caption data-ng-show="users" class="hidden">Table of realm users</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">
|
||||
<th colspan="{{access.impersonation == true ? '5' : '4'}}">
|
||||
<div class="form-inline">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<button class="btn btn-primary" ng-click="query.search = null; firstPage()">View all users</button>
|
||||
|
||||
<div class="pull-right">
|
||||
<div class="pull-right" data-ng-show="access.manageUsers">
|
||||
<a class="btn btn-primary" href="#/create/user/{{realm.realm}}">Add User</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,6 +29,7 @@
|
||||
<th>Last Name</th>
|
||||
<th>First Name</th>
|
||||
<th>Email</th>
|
||||
<th data-ng-show="access.impersonation"></th>
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -49,6 +50,7 @@
|
||||
<td>{{user.lastName}}</td>
|
||||
<td>{{user.firstName}}</td>
|
||||
<td>{{user.email}}</td>
|
||||
<td data-ng-show="access.impersonation"><button class="btn btn-default" data-ng-click="impersonate(user.id)">Impersonate</button></td>
|
||||
</tr>
|
||||
<tr data-ng-show="!users || users.length == 0">
|
||||
<td class="text-muted" data-ng-show="!users">Please enter a search, or click on view all users</td>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<#import "template.ftl" as layout>
|
||||
<@layout.registrationLayout displayInfo=social.displayInfo; section>
|
||||
<#if section = "title">
|
||||
${msg("imperonateTitle",(realm.name!''))}
|
||||
<#elseif section = "header">
|
||||
${msg("impersonateTitleHtml",(realm.name!''))}
|
||||
<#elseif section = "form">
|
||||
<form id="kc-form-login" class="${properties.kcFormClass!}" action="${url.loginAction}" method="post">
|
||||
<input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
|
||||
<#if realmList??>
|
||||
<div class="${properties.kcFormGroupClass!}">
|
||||
<div class="${properties.kcLabelWrapperClass!}">
|
||||
<label for="realm" class="${properties.kcLabelClass!}">${msg("realmChoice")}</label>
|
||||
</div>
|
||||
|
||||
<div class="${properties.kcInputWrapperClass!}">
|
||||
<select class="${properties.kcInputClass!}" id="selectRealm" name="realm">
|
||||
<#list realmList as r>
|
||||
<option value="${r}">${r}</option>
|
||||
</#list>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
<div class="${properties.kcFormGroupClass!}">
|
||||
<div class="${properties.kcLabelWrapperClass!}">
|
||||
<label for="username" class="${properties.kcLabelClass!}"><#if !realm.registrationEmailAsUsername>${msg("usernameOrEmail")}<#else>${msg("email")}</#if></label>
|
||||
</div>
|
||||
|
||||
<div class="${properties.kcInputWrapperClass!}">
|
||||
<input id="username" class="${properties.kcInputClass!}" name="username" value="" type="text" autofocus />
|
||||
</div>
|
||||
</div>
|
||||
<div class="${properties.kcFormGroupClass!}">
|
||||
<div class="${properties.kcLabelWrapperClass!}">
|
||||
<label for="username" class="${properties.kcLabelClass!}"></label>
|
||||
</div>
|
||||
<div class="${properties.kcInputWrapperClass!}">
|
||||
<input class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}" name="impersonate" id="kc-impersonate" type="submit" value="${msg("doImpersonate")}"/>
|
||||
<input class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!}" name="cancel" id="kc-cancel" type="submit" value="${msg("doCancel")}"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</#if>
|
||||
</@layout.registrationLayout>
|
||||
Reference in new issue
Block a user