KEYCLOAK-3170 Users with only view-users and impersonate can't impersonate in the UI

This commit is contained in:
Stian Thorgersen 2016-07-15 07:52:21 +02:00
parent 2f14fb7fb7
commit f9bfb5d3e5
2 changed files with 14 additions and 10 deletions

View file

@ -2126,18 +2126,22 @@ module.directive('kcReadOnly', function() {
}
}
var filterIgnored = function(i, e){
return !e.attributes['kc-read-only-ignore'];
}
scope.$watch(attrs.kcReadOnly, function(readOnly) {
if (readOnly) {
element.find('input').each(disable);
element.find('button').each(disable);
element.find('select').each(disable);
element.find('textarea').each(disable);
element.find('input').filter(filterIgnored).each(disable);
element.find('button').filter(filterIgnored).each(disable);
element.find('select').filter(filterIgnored).each(disable);
element.find('textarea').filter(filterIgnored).each(disable);
} else {
element.find('input').each(enable);
element.find('input').each(enable);
element.find('button').each(enable);
element.find('select').each(enable);
element.find('textarea').each(enable);
element.find('input').filter(filterIgnored).each(enable);
element.find('input').filter(filterIgnored).each(enable);
element.find('button').filter(filterIgnored).each(enable);
element.find('select').filter(filterIgnored).each(enable);
element.find('textarea').filter(filterIgnored).each(enable);
}
});
}

View file

@ -117,7 +117,7 @@
<label class="col-md-2 control-label" for="impersonate">{{:: 'impersonate-user' | translate}}</label>
<div class="col-md-6">
<button id="impersonate" data-ng-show="access.impersonation" class="btn btn-default" data-ng-click="impersonate()">{{:: 'impersonate' | translate}}</button>
<button id="impersonate" data-ng-show="access.impersonation" kc-read-only-ignore class="btn btn-default" data-ng-click="impersonate()">{{:: 'impersonate' | translate}}</button>
</div>
<kc-tooltip>{{:: 'impersonate-user.tooltip' | translate}}</kc-tooltip>
</div>