From cbb8d4e1b6c3dc752e657d41a2a5f2a2ef976550 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Thu, 22 Mar 2018 16:11:25 +0100 Subject: [PATCH] Closes #216: redirect to login if not connected --- docs-web/src/main/webapp/src/app/docs/app.js | 3 ++- .../main/webapp/src/app/docs/controller/Main.js | 14 ++++++++++++++ .../webapp/src/app/docs/controller/Navigation.js | 4 ---- docs-web/src/main/webapp/src/index.html | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/Main.js diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index f51918e7..63638fbf 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -23,7 +23,8 @@ angular.module('docs', url: '', views: { 'page': { - templateUrl: 'partial/docs/main.html' + templateUrl: 'partial/docs/main.html', + controller: 'Main' } } }) diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Main.js b/docs-web/src/main/webapp/src/app/docs/controller/Main.js new file mode 100644 index 00000000..0716e640 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/Main.js @@ -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' + }); + } + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js index 60a901d0..6fa92d64 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js @@ -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' - }); } }); diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index 63d44847..01459c2b 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -49,6 +49,7 @@ +