mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
@@ -1,4 +1,4 @@
|
|||||||
|
from mock import patch
|
||||||
from django.forms import Form
|
from django.forms import Form
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
@@ -581,14 +581,9 @@ class TwoFactorLoginView(BaseTwoFactorLoginView):
|
|||||||
We need to override this function so that we can redirect to
|
We need to override this function so that we can redirect to
|
||||||
realm.uri instead of '/'.
|
realm.uri instead of '/'.
|
||||||
"""
|
"""
|
||||||
old_redirect_url = settings.LOGIN_REDIRECT_URL
|
realm_uri = self.get_user().realm.uri
|
||||||
try:
|
with patch.object(settings, 'LOGIN_REDIRECT_URL', realm_uri):
|
||||||
# TODO: Get django-two-factor to support this being an option.
|
return super().done(form_list, **kwargs)
|
||||||
settings.LOGIN_REDIRECT_URL = self.get_user().realm.uri
|
|
||||||
redirect_response = super().done(form_list, **kwargs)
|
|
||||||
finally:
|
|
||||||
settings.LOGIN_REDIRECT_URL = old_redirect_url
|
|
||||||
return redirect_response
|
|
||||||
|
|
||||||
def login_page(request: HttpRequest, **kwargs: Any) -> HttpResponse:
|
def login_page(request: HttpRequest, **kwargs: Any) -> HttpResponse:
|
||||||
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
||||||
|
|||||||
Reference in New Issue
Block a user