Skip to content

Commit 8bc4290

Browse files
committed
Stay on the current page when logging in or out
I've found that the majority of the time I use the user-switcher panel this is what I want. Especially as we're not actually running through the site's real login logic, it's relatively unlikely that the previous behaviour was correctly matching that anyway.
1 parent 36f4d08 commit 8bc4290

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

debug_toolbar_user_switcher/views.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ def login(request, **kwargs):
3232
user.backend = settings.AUTHENTICATION_BACKENDS[0]
3333
auth.login(request, user)
3434

35-
return HttpResponseRedirect(request.POST.get("next", "/"))
35+
return HttpResponseRedirect(
36+
request.POST.get("next", request.META.get("HTTP_REFERER", "/")),
37+
)
3638

3739

3840
@csrf_exempt
3941
@require_POST
4042
@debug_required
4143
def logout(request):
4244
django_logout(request)
43-
return HttpResponseRedirect(request.POST.get("next", "/"))
45+
return HttpResponseRedirect(
46+
request.POST.get("next", request.META.get("HTTP_REFERER", "/")),
47+
)

0 commit comments

Comments
 (0)