Ensures that if a user session times out and another user logs in that we redirect to root

This commit is contained in:
Shannon
2013-10-01 10:08:55 +10:00
parent 59196020bb
commit 79e35d5c06

View File

@@ -8,7 +8,7 @@
* The main application controller
*
*/
function MainController($scope, $routeParams, $rootScope, $timeout, $http, $log, notificationsService, userService, navigationService, legacyJsLoader) {
function MainController($scope, $location, $routeParams, $rootScope, $timeout, $http, $log, notificationsService, userService, navigationService, legacyJsLoader) {
var legacyTreeJsLoaded = false;
@@ -78,6 +78,12 @@ function MainController($scope, $routeParams, $rootScope, $timeout, $http, $log,
$scope.authenticated = data.authenticated;
$scope.user = data.user;
//if the user has changed we need to redirect to the root so they don't try to continue editing the
//last item in the URL
if (data.lastUserId !== data.user.id) {
$location.path("/").search("");
}
//var url = "http://www.gravatar.com/avatar/" + $scope.user.emailHash + ".json?404=404";
//$http.jsonp(url).then(function(response){
// $log.log("found: " + response);