Skip to content

Commit

Permalink
redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
BinamB committed Aug 13, 2020
1 parent 027a4a2 commit 998b6da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 7 additions & 7 deletions fence/blueprints/login/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from fence.auth import login_user
from fence.blueprints.login.redirect import validate_redirect
from fence.config import config
from fence.errors import UserError, MovedTemporarily
from fence.errors import UserError


class DefaultOAuth2Login(Resource):
Expand Down Expand Up @@ -69,12 +69,12 @@ def __init__(self, idp_name, client, username_field="email"):
self.username_field = username_field

def get(self):
error = flask.request.args.get("error")
full_path = flask.request.full_path
if error:
err_msg = flask.request.args.get("error_description")
err = {"error": error, "error_description": err_msg}
raise MovedTemporarily(flask.jsonify(err))

if flask.request.args.get("error"):
# Check if user granted access
path_to_add = flask.request.full_path[flask.request.full_path.find("?") :]
location = flask.session.get("redirect") or config["BASE_URL"]
return flask.redirect(location=location + path_to_add)

code = flask.request.args.get("code")
result = self.client.get_user_id(code)
Expand Down
6 changes: 0 additions & 6 deletions fence/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,3 @@ class UnavailableError(APIError):
def __init__(self, message):
self.message = str(message)
self.code = 503


class MovedTemporarily(APIError):
def __init__(self, message):
self.message = str(message)
self.code = 302

0 comments on commit 998b6da

Please sign in to comment.