Skip to content

Commit

Permalink
error message
Browse files Browse the repository at this point in the history
  • Loading branch information
BinamB committed Aug 12, 2020
1 parent 9b7df87 commit 027a4a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 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
from fence.errors import UserError, MovedTemporarily


class DefaultOAuth2Login(Resource):
Expand Down Expand Up @@ -69,6 +69,13 @@ 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))

code = flask.request.args.get("code")
result = self.client.get_user_id(code)
username = result.get(self.username_field)
Expand Down
6 changes: 6 additions & 0 deletions fence/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ 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 027a4a2

Please sign in to comment.