Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

skip token refresh for unauthenticated (public) users (#2703)

Wouter Voorbergca5605d40f01
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 36d99afe4..34d32f401 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -994,6 +994,9 @@ export class Manager implements EventProviderFactory {
}
protected _createTokenUpdateInterval() {
+ if (!this._authenticated) {
+ return;
+ }
if (!this._keycloakUpdateTokenInterval) {
this._keycloakUpdateTokenInterval = window.setInterval(async () => {
await this._updateKeycloakAccessToken().catch(() => {
@@ -1091,6 +1094,17 @@ export class Manager implements EventProviderFactory {
const tryReconnect = async () => {
console.debug("Reconnecting to the Manager...");
+
+ // If the user was never authenticated (public access), skip token refresh and just reconnect the event provider.
+ if (!this._authenticated) {
+ console.debug("User is not authenticated, skipping token refresh");
+ const isEventsOnline = () => this.events?.status === EventProviderStatus.CONNECTED;
+ if (!isEventsOnline()) {
+ await this.events?.connect();
+ }
+ return isEventsOnline();
+ }
+
const keycloakOffline = !await this.isKeycloakReachable();
if (keycloakOffline) {