| .. | .. |
|---|
| 67 | 67 | m.controller('MainCtrl', ['$scope', '$http', '$location', '$L', '$store', |
|---|
| 68 | 68 | function($scope, $http, $location, $L, $store) { |
|---|
| 69 | 69 | |
|---|
| 70 | + $location.path('/login'); |
|---|
| 70 | 71 | if ($store.get('token') != null) { |
|---|
| 71 | | - $http.defaults.headers.common['X-SECURIS-TOKEN'] = $store.get('token'); |
|---|
| 72 | | - $location.path('/licenses'); |
|---|
| 73 | | - } else { |
|---|
| 74 | | - $location.path('/login'); |
|---|
| 72 | + |
|---|
| 73 | + $http.get('/check', { |
|---|
| 74 | + headers: { |
|---|
| 75 | + 'X-SECURIS-TOKEN': $store.get('token') |
|---|
| 76 | + } |
|---|
| 77 | + }).success(function(data) { |
|---|
| 78 | + if (data.valid) { |
|---|
| 79 | + $http.defaults.headers.common['X-SECURIS-TOKEN'] = $store.get('token'); |
|---|
| 80 | + $location.path('/licenses'); |
|---|
| 81 | + $store.set('user', data.user); |
|---|
| 82 | + } |
|---|
| 83 | + }); |
|---|
| 75 | 84 | } |
|---|
| 76 | 85 | |
|---|
| 77 | 86 | $scope.logout = function() { |
|---|