From fb0f12a51fe8bef47b9623869aed20beba86887d Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 16 Sep 2017 13:34:55 +0200 Subject: [PATCH] Maintain redirection URL across oauth signup Previously when signing up for a new account in the middle of an authentication process, the final redirection URL was lost and the user was sent back to the /account/ page. Instead, we now redirect to the proper URL (for sending back to the community auth client site) if it's available in the session, both for successful signup and for canceled logins. --- pgweb/account/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pgweb/account/views.py b/pgweb/account/views.py index ccbc8b90..3f4e3d9f 100644 --- a/pgweb/account/views.py +++ b/pgweb/account/views.py @@ -360,14 +360,15 @@ def signup_oauth(request): user.backend = settings.AUTHENTICATION_BACKENDS[0] django_login(request, user) - # Redirect to the account page - return HttpResponseRedirect('/account/') + # Redirect to the sessions page, or to the account page + # if none was given. + return HttpResponseRedirect(request.session.pop('login_next', '/account/')) elif request.GET.has_key('do_abort'): del request.session['oauth_email'] del request.session['oauth_firstname'] del request.session['oauth_lastname'] request.session.modified = True - return HttpResponseRedirect('/') + return HttpResponseRedirect(request.session.pop('login_next', '/')) else: # Generate possible new username suggested_username = request.session['oauth_email'].replace('@', '.')[:30] -- 2.39.5