Skip to content

Instantly share code, notes, and snippets.

@jonathanjacob
Last active May 5, 2019 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jonathanjacob/cc4c3512fafe331a5d379d27606d4102 to your computer and use it in GitHub Desktop.
Save jonathanjacob/cc4c3512fafe331a5d379d27606d4102 to your computer and use it in GitHub Desktop.
Service Portal Impersonation
//Be sure and include spModal in the function
function ($rootScope, $scope, snRecordWatcher, spUtil, spModal, $location, $uibModal, cabrillo, $timeout) {
//Impersonation
$scope.openImpersonationDialog = function(){
spModal.open({
title: "Impersonate User",
widget: "service-catalyst-impersonate",
buttons: [
{label:'Close', cancel: true}
],
widgetInput: {}
}).then(function(){
console.log('closed impersonation');
})
}
}
<ul class="dropdown-menu">
<!-- Insert the line below approx (line 33) in Stock header -->
<li><a ng-if="data.canImpersonate" ng-click="openImpersonationDialog()">${Impersonate User}</a></li>
<!-- Insert the line above -->
<li><a ng-if="data.isImpersonating" ng-click="impersonate(data.realUser)">${Stop Impersonating}</a></li>
<li><a ng-href="?id=user_profile&sys_id={{::user.sys_id}}">${Profile}</a></li>
<li><a href="{{::portal.logoutUrl}}">${Logout}</a></li>
</ul>
//Impersonation
data.canImpersonate = new GlideImpersonate().canImpersonate(gs.getUserID());
data.isImpersonating = new GlideImpersonate().isImpersonating();
data.realUser = gs.getImpersonatingUserName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment