Skip to content

Commit

Permalink
Merge e1f24bc into d2c1258
Browse files Browse the repository at this point in the history
  • Loading branch information
BinamB committed Aug 14, 2020
2 parents d2c1258 + e1f24bc commit 955ec70
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fence/blueprints/login/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import flask
from flask_restful import Resource
from urllib.parse import urlparse, urljoin

from fence.auth import login_user
from fence.blueprints.login.redirect import validate_redirect
Expand Down Expand Up @@ -69,6 +70,15 @@ def __init__(self, idp_name, client, username_field="email"):
self.username_field = username_field

def get(self):

if flask.request.args.get("error"):
# Check if user granted access
url = flask.request.url
parsed_url = urlparse(url)
location = flask.session.get("redirect") or config["BASE_URL"]
redirect_url = urljoin(location, parsed_url.path)
return flask.redirect(location=redirect_url)

code = flask.request.args.get("code")
result = self.client.get_user_id(code)
username = result.get(self.username_field)
Expand Down

0 comments on commit 955ec70

Please sign in to comment.