Finishes: U4-2678 Fix logging out and then logging in as another user, the sections, etc... do not get updated.
This commit is contained in:
@@ -60,7 +60,6 @@ angular.module("umbraco.directives")
|
||||
if (scope.eventhandler) {
|
||||
$(scope.eventhandler).trigger(eventName, args);
|
||||
}
|
||||
// $rootScope.$broadcast(eventName, args);
|
||||
}
|
||||
|
||||
/** Method to load in the tree data */
|
||||
@@ -93,7 +92,7 @@ angular.module("umbraco.directives")
|
||||
* When changing sections we don't want all of the tree-ndoes to do their 'leave' animations.
|
||||
*/
|
||||
scope.animation = function () {
|
||||
if (enableDeleteAnimations && scope.tree.root.expanded) {
|
||||
if (enableDeleteAnimations && scope.tree && scope.tree.root && scope.tree.root.expanded) {
|
||||
return { leave: 'tree-node-delete-leave' };
|
||||
}
|
||||
else {
|
||||
@@ -126,8 +125,17 @@ angular.module("umbraco.directives")
|
||||
}
|
||||
});
|
||||
|
||||
//initial change
|
||||
loadTree();
|
||||
//When the user logs in
|
||||
scope.$on("authenticated", function (evt, data) {
|
||||
//populate the tree if the user has changed
|
||||
if (data.lastUserId !== data.user.id) {
|
||||
treeService.clearCache();
|
||||
scope.tree = null;
|
||||
loadTree();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
* The tree service factory, used internally by the umbTree and umbTreeItem directives
|
||||
*/
|
||||
function treeService($q, treeResource, iconHelper, notificationsService, $rootScope) {
|
||||
//implement this in local storage
|
||||
|
||||
//TODO: implement this in local storage
|
||||
var treeArray = [];
|
||||
|
||||
var standardCssClass = 'icon umb-tree-icon sprTree';
|
||||
|
||||
return {
|
||||
@@ -58,6 +60,11 @@ function treeService($q, treeResource, iconHelper, notificationsService, $rootSc
|
||||
}
|
||||
},
|
||||
|
||||
/** clears the tree cache */
|
||||
clearCache: function() {
|
||||
treeArray = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.treeService#loadNodeChildren
|
||||
@@ -259,6 +266,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, $rootSc
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,10 @@ angular.module('umbraco.services')
|
||||
securityRetryQueue.onItemAddedCallbacks.push(function (retryItem) {
|
||||
if (securityRetryQueue.hasMore()) {
|
||||
|
||||
//clear the user
|
||||
lastUserId = currentUser.id;
|
||||
//store the last user id and clear the user
|
||||
if (currentUser && currentUser.id !== undefined) {
|
||||
lastUserId = currentUser.id;
|
||||
}
|
||||
currentUser = null;
|
||||
|
||||
//broadcast a global event that the user is no longer logged in
|
||||
@@ -63,7 +65,7 @@ angular.module('umbraco.services')
|
||||
}
|
||||
else {
|
||||
|
||||
var result = { user: data, authenticated: true };
|
||||
var result = { user: data, authenticated: true, lastUserId: lastUserId };
|
||||
|
||||
if (args.broadcastEvent) {
|
||||
//broadcast a global event, will inform listening controllers to load in the user specific data
|
||||
@@ -86,7 +88,7 @@ angular.module('umbraco.services')
|
||||
//when it's successful, return the user data
|
||||
currentUser = data;
|
||||
|
||||
var result = { user: data, authenticated: true, previousUserId: lastUserId };
|
||||
var result = { user: data, authenticated: true, lastUserId: lastUserId };
|
||||
|
||||
//broadcast a global event
|
||||
$rootScope.$broadcast("authenticated", result);
|
||||
|
||||
@@ -33,19 +33,16 @@ function NavigationController($scope,$rootScope, $location, $log, $routeParams,
|
||||
|
||||
$scope.selectedId = navigationService.currentId;
|
||||
$scope.sections = navigationService.sections;
|
||||
|
||||
//When the user logs out or times out
|
||||
$scope.$on("notAuthenticated", function () {
|
||||
|
||||
});
|
||||
|
||||
//When the user logs in
|
||||
$scope.$on("authenticated", function (evt, data) {
|
||||
//populate their sections if the user hasn't changed
|
||||
sectionResource.getSections()
|
||||
.then(function(result) {
|
||||
$scope.sections = result;
|
||||
});
|
||||
//populate their sections if the user has changed
|
||||
if (data.lastUserId !== data.user.id) {
|
||||
sectionResource.getSections()
|
||||
.then(function (result) {
|
||||
$scope.sections = result;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//This reacts to clicks passed to the body element which emits a global call to close all dialogs
|
||||
|
||||
Reference in New Issue
Block a user