Closes #216: redirect to login if not connected

This commit is contained in:
Benjamin Gamard 2018-03-22 16:11:25 +01:00
parent 785ad7f3a1
commit cbb8d4e1b6
4 changed files with 17 additions and 5 deletions

View File

@ -23,7 +23,8 @@ angular.module('docs',
url: '',
views: {
'page': {
templateUrl: 'partial/docs/main.html'
templateUrl: 'partial/docs/main.html',
controller: 'Main'
}
}
})

View File

@ -0,0 +1,14 @@
'use strict';
/**
* Main controller.
*/
angular.module('docs').controller('Main', function($scope, $rootScope, $state, User) {
User.userInfo().then(function(data) {
if (!data.anonymous) {
$state.go('document.default', {}, {
location: 'replace'
});
}
});
});

View File

@ -10,10 +10,6 @@ angular.module('docs').controller('Navigation', function($scope, $state, $rootSc
$state.go('login', {}, {
location: 'replace'
});
} else {
$state.go('document.default', {}, {
location: 'replace'
});
}
});

View File

@ -49,6 +49,7 @@
<script src="lib/angular.timeago.js" type="text/javascript"></script>
<script src="app/docs/app.js" type="text/javascript"></script>
<script src="app/docs/controller/Login.js" type="text/javascript"></script>
<script src="app/docs/controller/Main.js" type="text/javascript"></script>
<script src="app/docs/controller/ModalPasswordLost.js" type="text/javascript"></script>
<script src="app/docs/controller/ModalFeedback.js" type="text/javascript"></script>
<script src="app/docs/controller/ModalImport.js" type="text/javascript"></script>