diff options
-rw-r--r-- | app/common/services/userModel.js | 9 | ||||
-rw-r--r-- | app/index.js | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/app/common/services/userModel.js b/app/common/services/userModel.js index f73c7a8..ca90165 100644 --- a/app/common/services/userModel.js +++ b/app/common/services/userModel.js @@ -11,8 +11,8 @@ window.angular && (function(angular) { 'use strict'; angular.module('app.common.services').service('userModel', [ - 'APIUtils', - function(APIUtils) { + '$cookies', 'APIUtils', + function($cookies, APIUtils) { return { login: function(username, password, callback) { APIUtils.login(username, password, function(response, error) { @@ -35,7 +35,9 @@ window.angular && (function(angular) { }); }, isLoggedIn: function() { - if (sessionStorage.getItem('LOGIN_ID') === null) { + if ((sessionStorage.getItem('LOGIN_ID') === null) && + (($cookies.get('IsAuthenticated') === undefined) || + ($cookies.get('IsAuthenticated') == 'false'))) { return false; } return true; @@ -46,6 +48,7 @@ window.angular && (function(angular) { response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS) { sessionStorage.removeItem('LOGIN_ID'); sessionStorage.removeItem(APIUtils.HOST_SESSION_STORAGE_KEY); + $cookies.remove('IsAuthenticated'); callback(true); } else if (response.status == APIUtils.API_RESPONSE.ERROR_STATUS) { callback(false); diff --git a/app/index.js b/app/index.js index eb27a34..57d031b 100644 --- a/app/index.js +++ b/app/index.js @@ -126,7 +126,7 @@ window.angular && (function(angular) { // Dependencies 'ngRoute', 'angular-clipboard', 'ngToast', 'ngAnimate', 'ngMessages', 'app.common.directives.dirPagination', 'ngSanitize', - 'ui.bootstrap', + 'ui.bootstrap', 'ngCookies', // Basic resources 'app.common.services', 'app.common.directives', 'app.common.filters', 'app.common.components', @@ -184,8 +184,8 @@ window.angular && (function(angular) { } ]) .run([ - '$rootScope', '$location', 'dataService', 'userModel', - function($rootScope, $location, dataService, userModel) { + '$rootScope', '$location', 'dataService', 'userModel', '$cookies', + function($rootScope, $location, dataService, userModel, $cookies) { $rootScope.dataService = dataService; dataService.path = $location.path(); $rootScope.$on('$routeChangeStart', function(event, next, current) { @@ -219,7 +219,10 @@ window.angular && (function(angular) { }); $rootScope.$on('timedout-user', function() { + console.log('timedout-user event triggered'); sessionStorage.removeItem('LOGIN_ID'); + $cookies.remove('IsAuthenticated'); + $location.path('/login'); }); } |