diff --git a/angularjs.userapp.js b/angularjs.userapp.js index 433513a..7f64615 100755 --- a/angularjs.userapp.js +++ b/angularjs.userapp.js @@ -296,26 +296,30 @@ var userappModule = angular.module('UserApp', []); // Load the logged in user this.loadUser(function(error, result) { - callback && callback(error, result); - $rootScope.$broadcast('user.login'); + if (!error) { + callback && callback(error, result); + $rootScope.$broadcast('user.login'); - // Check permissions for this route - if ($state) { - if ($state.$current && $state.$current.data && $state.$current.data.hasPermission) { - if (!that.hasPermission($state.$current.data.hasPermission)) { - $timeout(function() { - transitionTo(defaultRoute, true); - }); + // Check permissions for this route + if ($state) { + if ($state.$current && $state.$current.data && $state.$current.data.hasPermission) { + if (!that.hasPermission($state.$current.data.hasPermission)) { + $timeout(function() { + transitionTo(defaultRoute, true); + }); + } } - } - } else if ($route) { - if ($route.current && $route.current.$$route.hasPermission) { - if (!that.hasPermission($route.current.$$route.hasPermission)) { - $timeout(function() { - transitionTo(defaultRoute); - }); + } else if ($route) { + if ($route.current && $route.current.$$route.hasPermission) { + if (!that.hasPermission($route.current.$$route.hasPermission)) { + $timeout(function() { + transitionTo(defaultRoute); + }); + } } } + } else { + that.reset(); } }); }, diff --git a/bower.json b/bower.json index 13bd04d..c15ef9f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "userapp-angular", - "version": "1.6.0", + "version": "1.6.1", "main": "./angularjs.userapp.js", "dependencies": { "userapp": "latest"