diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index bb6934f01..bcb471bb3 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -171,8 +171,8 @@ - - + + diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index 9e19f8338..8f08d537f 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -139,9 +139,9 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) // Put the operator into the root scope $http.get('/users/whoami/').success(function(data) { operator.setUser(data.user_id); - if (data.user_id == null) { + if (data.user_id === null) { // redirect to login dialog if use is not logged in - $state.go('login'); + $state.go('login', {guest_enabled: data.guest_enabled}); } }); $rootScope.operator = operator; diff --git a/openslides/users/views.py b/openslides/users/views.py index 85bef6add..905f600ce 100644 --- a/openslides/users/views.py +++ b/openslides/users/views.py @@ -229,12 +229,12 @@ class WhoAmIView(APIView): def get_context_data(self, **context): """ - Appends the user id to the context. - - Uses None for the anonymous user. + Appends the user id to the context. Uses None for the anonymous + user. Appends also a flag if guest users are enabled in the config. """ return super().get_context_data( user_id=self.request.user.pk, + guest_enabled=config['general_system_enable_anonymous'], **context) diff --git a/tests/integration/users/test_views.py b/tests/integration/users/test_views.py index 97d3b2bb0..97a7678be 100644 --- a/tests/integration/users/test_views.py +++ b/tests/integration/users/test_views.py @@ -12,7 +12,9 @@ class TestWhoAmIView(TestCase): response = self.client.get(self.url) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'{"user_id":null}') + self.assertEqual( + json.loads(response.content.decode('utf-8')), + {'user_id': None, 'guest_enabled': False}) def test_get_authenticated_user(self): self.client.login(username='admin', password='admin') @@ -20,7 +22,9 @@ class TestWhoAmIView(TestCase): response = self.client.get(self.url) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'{"user_id":1}') + self.assertEqual( + json.loads(response.content.decode('utf-8')), + {'user_id': 1, 'guest_enabled': False}) def test_post(self): response = self.client.post(self.url)