Use request again and catch all errors
All checks were successful
continuous-integration/drone/push Build is passing

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

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>")
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")