se-hub/templates/js/controllers/mainController.js

26 lines
670 B
JavaScript
Raw Normal View History

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