limitless.directive('userMenuItem', ['Zupit.Identity.AuthService','$state','Zupit.Core.NotificationService','Zupit.Core.AppService','$rootScope', function (auth,$state,notify,app,$rootScope) { 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(); } } } } }]);