Commit d1d6e1af authored by Claude Paroz's avatar Claude Paroz

Fixes #92 - Repaired redirection after login

Regression in d44360a3.
parent 63342365
Pipeline #24438 failed with stage
in 2 minutes and 10 seconds
......@@ -44,6 +44,13 @@ def about(request):
class LoginView(AuthLoginView):
form_class = LoginForm
redirect_field_name = 'referer'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if not context['referer']:
context['referer'] = self.request.META.get('HTTP_REFERER', '')
return context
def form_valid(self, form):
response = super().form_valid(form)
......
......@@ -58,6 +58,12 @@ class PeopleTestCase(TestCase):
def test_login_message(self):
self.pn = self._create_person()
response = self.client.get(reverse('login'), HTTP_REFERER='http://foo/bar')
self.assertContains(
response,
'<input type="hidden" name="referer" value="http://foo/bar">',
html=True
)
response = self.client.post(
reverse('login'), data={'username': 'jn', 'password': 'password'}, follow=True
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment