From a205a4c3636187e65daf3da3f0827413beee06cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Carrasqueira?= Date: Mon, 10 Jul 2023 22:01:05 -0300 Subject: [PATCH] Change login page to a variable setting the user wish to custom urls for two_factor and I think doing in this way could be more flexible --- two_factor/views/mixins.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/two_factor/views/mixins.py b/two_factor/views/mixins.py index 0f37fae79..635114f6a 100644 --- a/two_factor/views/mixins.py +++ b/two_factor/views/mixins.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.views import redirect_to_login from django.core.exceptions import PermissionDenied @@ -46,7 +47,12 @@ def get_login_url(self): """ Returns login url to redirect to. """ - return self.login_url and str(self.login_url) or reverse('two_factor:login') + login_redirect = 'two_factor:login' + + if settings.LOGIN_URL: + login_redirect = settings.LOGIN_URL + + return self.login_url and str(self.login_url) or reverse(login_redirect) def get_verification_url(self): """