Use request again and catch all errors
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2021-06-11 17:28:37 +02:00
parent 8e4c57029a
commit 96b6ceba70
Signed by: decentral1se
GPG Key ID: 92DAD76BD9567B8A
1 changed files with 6 additions and 6 deletions

View File

@ -48,12 +48,12 @@ async def login_keycloak(request: Request):
@app.get("/auth")
async def auth(request: Request):
try:
token = await oauth.keycloak.authorize_access_token()
except OAuthError as error:
return HTMLResponse(f"<h1>{error.error}</h1>")
user = await oauth.keycloak.parse_id_token(request, token)
request.session["user"] = dict(user)
return RedirectResponse(request.url_for("home"))
token = await oauth.keycloak.authorize_access_token(request)
user = await oauth.keycloak.parse_id_token(request, token)
request.session["user"] = dict(user)
return RedirectResponse(request.url_for("home"))
except Exception as exception:
return HTMLResponse(f"<h1>{str(exception)}</h1>")
@app.route("/logout")