Closes #216: redirect to login if not connected

This commit is contained in:
Benjamin Gamard 2018-03-22 15:05:24 +01:00
parent 5d9b87dace
commit 785ad7f3a1
6 changed files with 11 additions and 23 deletions

View File

@ -203,7 +203,6 @@ public class DocumentDao {
Map<String, Object> parameterMap = new HashMap<>(); Map<String, Object> parameterMap = new HashMap<>();
List<String> criteriaList = new ArrayList<>(); List<String> criteriaList = new ArrayList<>();
// TODO Simplify SELECT clause for count(*)
StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, "); StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, ");
sb.append(" s.count c5, "); sb.append(" s.count c5, ");
sb.append(" f.count c6, "); sb.append(" f.count c6, ");

View File

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

View File

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

View File

@ -6,6 +6,15 @@
angular.module('docs').controller('Navigation', function($scope, $state, $rootScope, User) { angular.module('docs').controller('Navigation', function($scope, $state, $rootScope, User) {
User.userInfo().then(function(data) { User.userInfo().then(function(data) {
$rootScope.userInfo = data; $rootScope.userInfo = data;
if (data.anonymous) {
$state.go('login', {}, {
location: 'replace'
});
} else {
$state.go('document.default', {}, {
location: 'replace'
});
}
}); });
/** /**

View File

@ -6,6 +6,6 @@
angular.module('docs').controller('Settings', function($scope, User) { angular.module('docs').controller('Settings', function($scope, User) {
// Flag if the user is admin // Flag if the user is admin
User.userInfo().then(function(data) { User.userInfo().then(function(data) {
$scope.isAdmin = data.base_functions.indexOf('ADMIN') != -1; $scope.isAdmin = data.base_functions.indexOf('ADMIN') !== -1;
}) })
}); });

View File

@ -48,7 +48,6 @@
<script src="lib/angular.qrcode.js" type="text/javascript"></script> <script src="lib/angular.qrcode.js" type="text/javascript"></script>
<script src="lib/angular.timeago.js" type="text/javascript"></script> <script src="lib/angular.timeago.js" type="text/javascript"></script>
<script src="app/docs/app.js" type="text/javascript"></script> <script src="app/docs/app.js" type="text/javascript"></script>
<script src="app/docs/controller/Main.js" type="text/javascript"></script>
<script src="app/docs/controller/Login.js" type="text/javascript"></script> <script src="app/docs/controller/Login.js" type="text/javascript"></script>
<script src="app/docs/controller/ModalPasswordLost.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/ModalFeedback.js" type="text/javascript"></script>