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