Added invalid Token redirection to Welcome app.js

This commit is contained in:
Sagi Dayan 2015-07-25 14:20:29 +03:00
parent 33003c0486
commit e9dab54c2c

View file

@ -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/';
});