mirror of
				https://gitlab.nic.cz/turris/reforis/foris-js.git
				synced 2025-10-31 22:30:31 +01:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -21,13 +21,13 @@ export class WebSockets { | |||||||
|     constructor() { |     constructor() { | ||||||
|         this.ws = new WebSocket(URL); |         this.ws = new WebSocket(URL); | ||||||
|         this.ws.onerror = (e) => { |         this.ws.onerror = (e) => { | ||||||
|             if (window.location.pathname !== ForisURLs.login) { |             if (!window.initialData.logged) { | ||||||
|                 console.error( |                 console.error( | ||||||
|                     "WS: Error observed, you aren't logged probably." |                     "WS: Error observed, you aren't logged probably." | ||||||
|                 ); |                 ); | ||||||
|                 window.location.replace(ForisURLs.login); |                 window.location.replace(ForisURLs.login); | ||||||
|             } |             } | ||||||
|             console.error(`WS: Error: ${e}`); |             console.error("WS: Error:", e); | ||||||
|         }; |         }; | ||||||
|         this.ws.onmessage = (e) => { |         this.ws.onmessage = (e) => { | ||||||
|             console.debug(`WS: Received Message: ${e.data}`); |             console.debug(`WS: Received Message: ${e.data}`); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user