Fixed #25032 -- Removed double redirect in admin login.
This commit is contained in:
parent
0e3193a386
commit
3353684102
|
@ -394,7 +394,7 @@ class AdminSite(object):
|
|||
)
|
||||
if (REDIRECT_FIELD_NAME not in request.GET and
|
||||
REDIRECT_FIELD_NAME not in request.POST):
|
||||
context[REDIRECT_FIELD_NAME] = request.get_full_path()
|
||||
context[REDIRECT_FIELD_NAME] = reverse('admin:index', current_app=self.name)
|
||||
context.update(extra_context or {})
|
||||
|
||||
defaults = {
|
||||
|
|
|
@ -1421,7 +1421,7 @@ class AdminViewPermissionsTest(TestCase):
|
|||
login_url = '%s?next=%s' % (reverse('admin:login'), reverse('admin:index'))
|
||||
# Super User
|
||||
response = self.client.get(self.index_url)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertRedirects(response, login_url)
|
||||
login = self.client.post(login_url, self.super_login)
|
||||
self.assertRedirects(login, self.index_url)
|
||||
self.assertFalse(login.context)
|
||||
|
@ -1480,6 +1480,15 @@ class AdminViewPermissionsTest(TestCase):
|
|||
form = login.context[0].get('form')
|
||||
self.assertEqual(form.errors['username'][0], 'This field is required.')
|
||||
|
||||
def test_login_redirect_for_direct_get(self):
|
||||
"""
|
||||
Login redirect should be to the admin index page when going directly to
|
||||
/admin/login/.
|
||||
"""
|
||||
response = self.client.get(reverse('admin:login'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.context[REDIRECT_FIELD_NAME], reverse('admin:index'))
|
||||
|
||||
def test_login_has_permission(self):
|
||||
# Regular User should not be able to login.
|
||||
response = self.client.get(reverse('has_permission_admin:index'))
|
||||
|
|
Loading…
Reference in New Issue