Skip to content

Commit

Permalink
TWLight.users.oauth: drop from_homepage url parameter when it isn't…
Browse files Browse the repository at this point in the history
… useful
  • Loading branch information
jsnshrmn committed Nov 8, 2021
1 parent 48ee749 commit 1935642
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions TWLight/users/oauth.py
Expand Up @@ -293,12 +293,15 @@ def get(self, request, *args, **kwargs):
next = query_dict.pop("next")
# Set the return url to the value of 'next'. Basic.
return_url = next[0]
# Pop the 'from_homepage' parameter out of the QueryDict.
# We don't need it here.
query_dict.pop("from_homepage", None)
# If there is anything left in the QueryDict after popping
# 'next', append it to the return url. This preserves state
# for filtered lists and redirected form submissions like
# the partner suggestion form.
if query_dict:
return_url += "?" + urlencode(query_dict)
return_url += "&" + urlencode(query_dict)
logger.info(
"User is already authenticated. Sending them on "
'for post-login redirection per "next" parameter.'
Expand Down Expand Up @@ -332,7 +335,8 @@ def get(self, request, *args, **kwargs):
next = query_dict.pop("next")
# Set the return url to the value of 'next'. Basic.
return_url = next[0]
from_homepage = query_dict.get("from_homepage", None)
# Pop the 'from_homepage' parameter out of the QueryDict.
from_homepage = query_dict.pop("from_homepage", None)

if from_homepage:
logger.info("Logging in from homepage, redirecting to Meta login")
Expand Down Expand Up @@ -513,12 +517,15 @@ def get(self, request, *args, **kwargs):
next = query_dict.pop("next")
# Set the return url to the value of 'next'. Basic.
return_url = next[0]
# Pop the 'from_homepage' parameter out of the QueryDict.
# We don't need it here.
query_dict.pop("from_homepage", None)
# If there is anything left in the QueryDict after popping
# 'next', append it to the return url. This preserves state
# for filtered lists and redirected form submissions like
# the partner suggestion form.
if query_dict:
return_url += "?" + urlencode(query_dict)
return_url += "&" + urlencode(query_dict)
logger.info(
"User authenticated. Sending them on for "
'post-login redirection per "next" parameter.'
Expand Down

0 comments on commit 1935642

Please sign in to comment.