Added guest enabled info to WhoAmI view.
This commit is contained in:
parent
c9adeb7fbb
commit
24cb58dc12
@ -139,9 +139,9 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
|||||||
// Put the operator into the root scope
|
// Put the operator into the root scope
|
||||||
$http.get('/users/whoami/').success(function(data) {
|
$http.get('/users/whoami/').success(function(data) {
|
||||||
operator.setUser(data.user_id);
|
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
|
// redirect to login dialog if use is not logged in
|
||||||
$state.go('login');
|
$state.go('login', {guest_enabled: data.guest_enabled});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$rootScope.operator = operator;
|
$rootScope.operator = operator;
|
||||||
|
@ -229,12 +229,12 @@ class WhoAmIView(APIView):
|
|||||||
|
|
||||||
def get_context_data(self, **context):
|
def get_context_data(self, **context):
|
||||||
"""
|
"""
|
||||||
Appends the user id to the context.
|
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.
|
||||||
Uses None for the anonymous user.
|
|
||||||
"""
|
"""
|
||||||
return super().get_context_data(
|
return super().get_context_data(
|
||||||
user_id=self.request.user.pk,
|
user_id=self.request.user.pk,
|
||||||
|
guest_enabled=config['general_system_enable_anonymous'],
|
||||||
**context)
|
**context)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ class TestWhoAmIView(TestCase):
|
|||||||
response = self.client.get(self.url)
|
response = self.client.get(self.url)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
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):
|
def test_get_authenticated_user(self):
|
||||||
self.client.login(username='admin', password='admin')
|
self.client.login(username='admin', password='admin')
|
||||||
@ -20,7 +22,9 @@ class TestWhoAmIView(TestCase):
|
|||||||
response = self.client.get(self.url)
|
response = self.client.get(self.url)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
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):
|
def test_post(self):
|
||||||
response = self.client.post(self.url)
|
response = self.client.post(self.url)
|
||||||
|
Loading…
Reference in New Issue
Block a user