mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-25 00:11:36 +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:
parent
67b8386cd0
commit
f3b1ef741a
|
@ -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}`);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user