mirror of
				https://gitlab.nic.cz/turris/reforis/foris-js.git
				synced 2025-11-03 23:00: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() {
 | 
			
		||||
        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}`);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user