1
0
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:
Aleksandr Gumroian 2021-06-14 17:29:33 +02:00
parent 67b8386cd0
commit f3b1ef741a
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733

View File

@ -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}`);