From 16c87d1a64841a8d6a496d9ba8b8a7b9de26e62c Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Thu, 7 Oct 2021 16:44:41 +0200
Subject: [PATCH] auth-keycloak: don't error out in case there are no entities

In case of the server template there are no enpoints registered by default,
but we still sue the keycloak login in the API docs. To avoid errors there
gracefully handle that case.
---
 packages/auth/src/auth-keycloak.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/packages/auth/src/auth-keycloak.js b/packages/auth/src/auth-keycloak.js
index 85aefa81..10238787 100644
--- a/packages/auth/src/auth-keycloak.js
+++ b/packages/auth/src/auth-keycloak.js
@@ -89,7 +89,14 @@ export class AuthKeycloak extends AdapterLitElement {
             baseUrl = jsonld.getApiUrlForEntityName("FrontendUser");
         } catch(error) {
             // backwards compat
-            baseUrl = jsonld.getApiUrlForEntityName("Person");
+            try {
+                baseUrl = jsonld.getApiUrlForEntityName("Person");
+            } catch(error) {
+                // There are no entities, just give up.
+                return {
+                    roles: [],
+                };
+            }
         }
         const apiUrl = baseUrl + '/' + encodeURIComponent(userId);
 
-- 
GitLab