limitless.directive('userMenuItem', ['Zupit.Identity.AuthService','$state','Zupit.Core.NotificationService','Zupit.Core.AppService','$rootScope','Zupit.Core.HttpClient', function (auth,$state,notify,app,$rootScope,$http) { return { restrict: 'E', templateUrl: config.baseUrl + 'app/components/usermenu.html', replace: true, scope: { user: '=', menu: '=' }, controller: function ($scope) { $scope.logout = function () { if (!app.canILeaveThePage()) { notify.confirm('ARE_YOU_SURE_DIRTY_FORM').then(function () { auth.logout(); }, function () { }); } else { auth.logout(); } } $scope.deimpersonate=function(){ $http.post("api/users/deimpersonate").then(function (data) { //$location.path('/'); //$route.reload(); app.Loading.show(); notify.success('SUCCESS_MESSAGE', 'IMPESONIFICATION_SUCCESS_TITLE_RELOAD'); $state.go('Dashboard'); setTimeout(function() { location.reload(true); },500); //$state.go('UserForm', { userId: userId }); }, function (err) { notify.error("Non è stato possibile deimpersonare un utente, riprova più tardi"); }); } } } }]);