From e9dab54c2cfa53e74576afb4bbc9070c3d7d40f8 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 25 Jul 2015 14:20:29 +0300 Subject: [PATCH] Added invalid Token redirection to Welcome app.js --- templates/js/controllers/mainController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 9fd22a2..2e6c04d 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,3 +1,5 @@ +var DEBUG = true; + angular.module('SeHub') .controller('mainController', ['$scope', '$rootScope', 'dataService', 'apiService', '$cookies', @@ -10,9 +12,11 @@ angular.module('SeHub') $scope.loadingData = true; $scope.isInRegisterMode = false; - apiService.getUserByToken(token).success(function(data) { - if (data.message == 'No User Found') { + apiService.getUserByToken(token).success(function(data, status) { + if (status == 204) { console.error("No User Found!"); + $cookieStore.remove('com.sehub.www'); + window.location = DEBUG ? 'http://localhost:8080' : 'http://se-hub.appstpot.com/'; } $scope.loadingData = false; $scope.user = data; @@ -60,6 +64,10 @@ angular.module('SeHub') $location.path('/home') } + }).error(function(err){ + console.error(err); + $cookieStore.remove('com.sehub.www'); + window.location = DEBUG ? 'http://localhost:8080' : 'http://se-hub.appstpot.com/'; });