From f3b1ef741a9851db716518680cf85ca3e117f675 Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Mon, 14 Jun 2021 17:29:33 +0200 Subject: [PATCH] Fix infinity redirect loop when WS error occurs There were situations when reForis infinity loop had occurred when the user was already logged in, but the client rejected the `wss` connection. The location path was not `/login`, and an infinity redirect took place. This should fix it. --- src/webSockets/WebSockets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webSockets/WebSockets.js b/src/webSockets/WebSockets.js index 55e3af5..a815656 100644 --- a/src/webSockets/WebSockets.js +++ b/src/webSockets/WebSockets.js @@ -21,13 +21,13 @@ export class WebSockets { constructor() { this.ws = new WebSocket(URL); this.ws.onerror = (e) => { - if (window.location.pathname !== ForisURLs.login) { + if (!window.initialData.logged) { console.error( "WS: Error observed, you aren't logged probably." ); window.location.replace(ForisURLs.login); } - console.error(`WS: Error: ${e}`); + console.error("WS: Error:", e); }; this.ws.onmessage = (e) => { console.debug(`WS: Received Message: ${e.data}`);