diff options
| author | ThinkChaos <ThinkChaos@users.noreply.github.com> | 2017-06-07 16:48:28 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-02-08 21:08:05 +0100 |
| commit | b99d6c9cbc8eecf480892599201eef0d14b20d71 (patch) | |
| tree | a563f6643d977ba1b97f2674da5e002a700399f5 /django | |
| parent | 59841170ba1785ada10a2915b0b60efdb046ee39 (diff) | |
Fixed #28216 -- Added next_page/get_default_redirect_url() to LoginView.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/views.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 529400df28..b5556aaa11 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -43,6 +43,7 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView): """ form_class = AuthenticationForm authentication_form = None + next_page = None redirect_field_name = REDIRECT_FIELD_NAME template_name = 'registration/login.html' redirect_authenticated_user = False @@ -63,8 +64,7 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView): return super().dispatch(request, *args, **kwargs) def get_success_url(self): - url = self.get_redirect_url() - return url or resolve_url(settings.LOGIN_REDIRECT_URL) + return self.get_redirect_url() or self.get_default_redirect_url() def get_redirect_url(self): """Return the user-originating redirect URL if it's safe.""" @@ -79,6 +79,10 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView): ) return redirect_to if url_is_safe else '' + def get_default_redirect_url(self): + """Return the default redirect URL.""" + return resolve_url(self.next_page or settings.LOGIN_REDIRECT_URL) + def get_form_class(self): return self.authentication_form or self.form_class |
