From bf2f9736fd096ee9a2f098005831919434084228 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 19 Oct 2021 14:53:50 +0200 Subject: [PATCH] auth: fallback path in case the API is down We still want to finish the auth process in that case, so the app can display some error message. --- packages/auth/src/auth-keycloak.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/auth-keycloak.js b/packages/auth/src/auth-keycloak.js index 10238787..6d625355 100644 --- a/packages/auth/src/auth-keycloak.js +++ b/packages/auth/src/auth-keycloak.js @@ -83,7 +83,15 @@ export class AuthKeycloak extends AdapterLitElement { } async _fetchUser(userId) { - let jsonld = await JSONLD.getInstance(this.entryPointUrl, this.lang); + let jsonld; + try { + jsonld = await JSONLD.getInstance(this.entryPointUrl, this.lang); + } catch(error) { + // Server is down, just give up. + return { + roles: [], + }; + } let baseUrl = ''; try { baseUrl = jsonld.getApiUrlForEntityName("FrontendUser"); -- GitLab