mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-05 22:14:45 +00:00
Check that the user has permission to see the admin dashboard before redirecting them there. Fixes #431
This commit is contained in:
parent
135f6e45d7
commit
90bdd0c501
2 changed files with 2 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ from django.contrib.auth.models import User, Group, Permission
|
|||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||
from django.core import mail
|
||||
|
||||
from wagtail.tests.utils import unittest, WagtailTestUtils
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailusers.models import UserProfile
|
||||
|
||||
|
||||
|
|
@ -62,7 +62,6 @@ class TestAuthentication(TestCase, WagtailTestUtils):
|
|||
# Check that the user was redirected to the dashboard
|
||||
self.assertRedirects(response, reverse('wagtailadmin_home'))
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_logged_in_as_non_privilaged_user_doesnt_redirect(self):
|
||||
"""
|
||||
This tests that if the user is logged in but hasn't got permission
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ def notification_preferences(request):
|
|||
@sensitive_post_parameters()
|
||||
@never_cache
|
||||
def login(request):
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated() and request.user.has_perm('wagtailadmin.access_admin'):
|
||||
return redirect('wagtailadmin_home')
|
||||
else:
|
||||
return auth_login(request,
|
||||
|
|
|
|||
Loading…
Reference in a new issue