From f050e04f0aafb84d90e99907d02a7cf8d41772dd Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Wed, 9 Dec 2015 20:45:52 +0100 Subject: [PATCH] Redirect to login dialog if user is not logged in (Fixes #1750) --- openslides/core/static/templates/index.html | 2 +- openslides/users/static/js/users/site.js | 22 ++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index 573f14312..bb6934f01 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -91,7 +91,7 @@
- + Login diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index e03313d8c..ee5a8009b 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -117,6 +117,15 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' }); } } + }) + .state('login', { + template: null, + onEnter: ['$stateParams', 'ngDialog', function($stateParams, ngDialog) { + ngDialog.open({ + template: 'static/templates/core/login-form.html', + controller: 'LoginFormCtrl', + }); + }] }); }) @@ -124,11 +133,16 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) 'operator', '$rootScope', '$http', + '$state', 'Group', - function(operator, $rootScope, $http, Group) { + function(operator, $rootScope, $http, $state, Group) { // Put the operator into the root scope $http.get('/users/whoami/').success(function(data) { operator.setUser(data.user_id); + if (data.user_id == null) { + // redirect to login dialog if use is not logged in + $state.go('login'); + } }); $rootScope.operator = operator; // Load all Groups. They are needed later @@ -696,12 +710,6 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) // DS.flush(); }); }; - $scope.openLoginForm = function () { - ngDialog.open({ - template: 'static/templates/core/login-form.html', - controller: 'LoginFormCtrl', - }); - }; } ])