Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional redirect check for google login #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flask_stormpath/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
)
from .models import User

# Add libraries to support url parsing from google redirect
import urllib,urlparse

def register():
"""
Expand Down Expand Up @@ -396,6 +398,12 @@ def google_login():
# Google user will be treated exactly like a normal Stormpath user!
login_user(account, remember=True)

# First check if redirect from google included a state parameter that contained the next url
if 'state' in request.args:
params = urlparse.parse_qs(urllib.unquote(request.args.get('state')))
if 'next' in params and len(params['next']) == 1:
return redirect(params['next'][0])

return redirect(request.args.get('next') or current_app.config['STORMPATH_REDIRECT_URL'])


Expand Down