Skip to content
Snippets Groups Projects
Commit 56607514 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

when a logout happens we need to listen for the event and clear the state of...

when a logout happens we need to listen for the event and clear the state of our top level controller so that the current user is no longer available.  this will also fix a problem where the nav bar was not hiding on logout.
parent fd36451e
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,13 @@ var CorvusControllers = angular.module('corvus.controllers', ['corvus.services']
CorvusControllers.controller('Corvus', ['$scope', '$location', 'CorvusCore', 'CorvusAlert', 'AppState', function($scope, $location, CorvusCore, CorvusAlert, AppState) {
var clearState = function() {
$scope.user = undefined;
$scope.userIsAdmin = false;
$scope.currentOrgSlug = undefined;
$scope.currentOrg = undefined;
};
// make our utilities object available throughout the application
$scope.utils = CorvusCore;
......@@ -36,6 +43,10 @@ CorvusControllers.controller('Corvus', ['$scope', '$location', 'CorvusCore', 'Co
$scope.userIsAdmin = AppState.userIsAdmin();
});
$scope.$on("appstate:logout", function (event, user) {
clearState();
});
$scope.closeAlert = function(index) {
CorvusAlert.closeAlert(index);
};
......
......@@ -14,7 +14,7 @@
</head>
<body ng-controller="Corvus">
<div ng-controller="Nav" ng-if="currentUser">
<div ng-controller="Nav" ng-if="user">
<nav class="CoreNav clearfix" ng-show="nav == 'main'">
<div class="col col-sm-12">
<div class="NavItem Dropdown float-left" dropdown on-toggle="toggled(open)">
......@@ -72,7 +72,7 @@
<ul class="Dropdown-content right">
<li class="" ><a class="link" href="/user/edit_current">Account Settings</a></li>
<li class="" ><a class="link" ng-if="userIsAdmin" cv-org-href="/admin/">Admin</a></li>
<li class="" ><a class="link" href="/auth/logout" target="_self">Logout</a></li>
<li class="" ><a class="link" href="/auth/logout">Logout</a></li>
</ul>
</li>
</ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment