2015-05-09 19:00:14 +00:00
|
|
|
angular.module('SeHub')
|
|
|
|
.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function ($scope, $rootScope, apiService, $cookies, $location) {
|
|
|
|
|
2015-06-15 15:41:44 +00:00
|
|
|
var token = $cookies['com.sehub.www'];
|
|
|
|
|
2015-05-09 19:00:14 +00:00
|
|
|
$scope.loadingData = true;
|
2015-06-15 15:41:44 +00:00
|
|
|
$scope.isInRegisterMode = false;
|
2015-05-09 19:00:14 +00:00
|
|
|
|
|
|
|
apiService.getUserByToken(token).success(function(data){
|
2015-06-15 15:41:44 +00:00
|
|
|
if(data.message == 'No User Found'){
|
2015-05-09 19:00:14 +00:00
|
|
|
console.error("No User Found!");
|
2015-06-15 15:41:44 +00:00
|
|
|
}
|
2015-05-09 19:00:14 +00:00
|
|
|
|
2015-06-09 17:16:29 +00:00
|
|
|
$scope.user = data;
|
2015-06-15 15:41:44 +00:00
|
|
|
if($scope.user.isFirstLogin){
|
|
|
|
$scope.menuObj = {};
|
|
|
|
$scope.isInRegisterMode = true;
|
|
|
|
$scope.loadingData = false;
|
2015-05-09 19:00:14 +00:00
|
|
|
$location.path('/register')
|
2015-06-16 11:15:59 +00:00
|
|
|
}else{
|
|
|
|
$location.path('/home')
|
2015-06-15 15:41:44 +00:00
|
|
|
}
|
2015-06-16 11:15:59 +00:00
|
|
|
|
2015-05-09 19:00:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
$scope.loadingData = false;
|
|
|
|
|
|
|
|
}]);
|