From 53142b57cba2e17b9d11cef300b746cda9767a64 Mon Sep 17 00:00:00 2001 From: "Timothy E. Johansson" Date: Sat, 26 Apr 2014 14:04:22 +0200 Subject: [PATCH] Fixed session timeout bug --- angularjs.userapp.js | 36 ++++++++++++++++++++---------------- bower.json | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) 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"