This reverts commit be2a57902f.
This commit is contained in:
@@ -11,6 +11,7 @@ import re
|
||||
import urllib
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import authenticate, get_user_model
|
||||
from django.contrib.auth import login as django_login
|
||||
from django.contrib.auth.decorators import login_required
|
||||
@@ -643,9 +644,13 @@ def login_refresh(request): # lint-amnesty, pylint: disable=missing-function-do
|
||||
|
||||
def redirect_to_lms_login(request):
|
||||
"""
|
||||
This view redirect the admin/login url to the site's login page.
|
||||
This view redirect the admin/login url to the site's login page if
|
||||
waffle switch is on otherwise returns the admin site's login view.
|
||||
"""
|
||||
return redirect('/login?next=/admin')
|
||||
if ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY.is_enabled():
|
||||
return redirect('/login?next=/admin')
|
||||
else:
|
||||
return admin.site.login(request)
|
||||
|
||||
|
||||
class LoginSessionView(APIView):
|
||||
|
||||
@@ -6,8 +6,11 @@ This is not inside a django app because it is a global property of the system.
|
||||
|
||||
from django.test import Client, TestCase
|
||||
from django.urls import reverse
|
||||
from edx_toggles.toggles.testutils import override_waffle_switch
|
||||
from common.djangoapps.student.tests.factories import UserFactory, TEST_PASSWORD
|
||||
|
||||
from openedx.core.djangoapps.user_authn.views.login import ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY
|
||||
|
||||
|
||||
class TestAdminView(TestCase):
|
||||
"""
|
||||
@@ -36,7 +39,10 @@ class TestAdminView(TestCase):
|
||||
assert response.status_code == 302
|
||||
|
||||
def test_admin_login_redirect(self):
|
||||
"""Admin login will redirect towards the site login page."""
|
||||
response = self.client.get(reverse('admin:login'))
|
||||
assert response.url == '/login?next=/admin'
|
||||
assert response.status_code == 302
|
||||
with override_waffle_switch(ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY, True):
|
||||
response = self.client.get(reverse('admin:login'))
|
||||
assert response.url == '/login?next=/admin'
|
||||
assert response.status_code == 302
|
||||
with override_waffle_switch(ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY, False):
|
||||
response = self.client.get(reverse('admin:login'))
|
||||
assert response.template_name == ['admin/login.html']
|
||||
|
||||
Reference in New Issue
Block a user