diff --git a/packages/auth/src/auth-keycloak.js b/packages/auth/src/auth-keycloak.js index 60c3b1612748f004d1fd3946942f2fa28c4da372..ddca6cb5abcf346f9f93ff1b64259a77e576b6e6 100644 --- a/packages/auth/src/auth-keycloak.js +++ b/packages/auth/src/auth-keycloak.js @@ -120,23 +120,30 @@ export class AuthKeycloak extends AdapterLitElement { if (newPerson && this.loadPerson) { JSONLD.getInstance(this.entryPointUrl).then((jsonld) => { - // find the correct api url for the current person - // we are fetching the logged-in person directly to respect the REST philosophy - // see: https://github.com/api-platform/api-platform/issues/337 - const apiUrl = jsonld.getApiUrlForEntityName("Person") + '/' + that.personId; - - fetch(apiUrl, { - headers: { - 'Content-Type': 'application/ld+json', - 'Authorization': 'Bearer ' + that.token, - }, - }) - .then(response => response.json()) - .then((person) => { - that.person = person; + try { + // find the correct api url for the current person + // we are fetching the logged-in person directly to respect the REST philosophy + // see: https://github.com/api-platform/api-platform/issues/337 + const apiUrl = jsonld.getApiUrlForEntityName("Person") + '/' + that.personId; + + fetch(apiUrl, { + headers: { + 'Content-Type': 'application/ld+json', + 'Authorization': 'Bearer ' + that.token, + }, + }) + .then(response => response.json()) + .then((person) => { + that.person = person; + this.sendSetPropertyEvents(); + this._setLoginStatus(this._loginStatus, true); + }); + } catch (error) { + console.warn(error); + that.person = null; this.sendSetPropertyEvents(); this._setLoginStatus(this._loginStatus, true); - }); + } }, {}, that.lang); } }