feat!: Remove django-admin default login (#29876)
* feat!: Remove django-admin default login
This commit is contained in:
@@ -7,12 +7,17 @@ from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
from urllib.parse import quote_plus # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from waffle.decorators import waffle_switch
|
||||
from django.contrib import admin
|
||||
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_response
|
||||
from openedx.core.djangoapps.user_authn.config.waffle import ADMIN_AUTH_REDIRECT_TO_LMS
|
||||
|
||||
from ..config import waffle
|
||||
|
||||
__all__ = ['register_redirect_to_lms', 'login_redirect_to_lms', 'howitworks', 'accessibility']
|
||||
__all__ = [
|
||||
'register_redirect_to_lms', 'login_redirect_to_lms', 'howitworks', 'accessibility',
|
||||
'redirect_to_lms_login_for_admin',
|
||||
]
|
||||
|
||||
|
||||
def register_redirect_to_lms(request):
|
||||
@@ -39,6 +44,16 @@ def login_redirect_to_lms(request):
|
||||
return redirect(login_url)
|
||||
|
||||
|
||||
def redirect_to_lms_login_for_admin(request):
|
||||
"""
|
||||
This view redirect the admin/login url to the site's login page.
|
||||
"""
|
||||
if ADMIN_AUTH_REDIRECT_TO_LMS.is_enabled():
|
||||
return redirect('/login?next=/admin')
|
||||
else:
|
||||
return admin.site.login(request)
|
||||
|
||||
|
||||
def _build_next_param(request):
|
||||
""" Returns the next param to be used with login or register. """
|
||||
next_url = request.GET.get('next')
|
||||
|
||||
Reference in New Issue
Block a user