From a66a2f47083e6535bf44929810aad7657b7201bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Sa=C5=A1ek?= Date: Fri, 27 Aug 2021 20:08:19 +0200 Subject: [PATCH 1/3] Remove reForis login page --- src/api/hooks.js | 7 +++---- src/api/utils.js | 5 +++-- src/utils/forisUrls.js | 4 ++-- src/webSockets/WebSockets.js | 10 +--------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/api/hooks.js b/src/api/hooks.js index a19732c..65a0bb1 100644 --- a/src/api/hooks.js +++ b/src/api/hooks.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/) * * This is free software, licensed under the GNU General Public License v3. * See /LICENSE for more information. @@ -7,7 +7,6 @@ import { useCallback, useEffect, useReducer, useState } from "react"; -import { ForisURLs } from "../utils/forisUrls"; import { API_ACTIONS, API_METHODS, @@ -84,8 +83,8 @@ function APIReducer(state, action) { data: action.payload, }; case API_ACTIONS.FAILURE: - if (action.status === 403) { - window.location.assign(ForisURLs.login); + if (action.status === 401) { + window.location.reload(); } // Not an API error - should be rethrown. diff --git a/src/api/utils.js b/src/api/utils.js index ba6d0d4..39943da 100644 --- a/src/api/utils.js +++ b/src/api/utils.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/) * * This is free software, licensed under the GNU General Public License v3. * See /LICENSE for more information. @@ -11,6 +11,7 @@ export const HEADERS = { Accept: "application/json", "Content-Type": "application/json", "X-CSRFToken": getCookie("_csrf_token"), + "X-Requested-With": "json", }; export const TIMEOUT = 30500; @@ -56,7 +57,7 @@ function getCookie(name) { export function getErrorPayload(error) { if (error.response) { - if (error.response.status === 403) { + if (error.response.status === 401) { return _("The session is expired. Please log in again."); } return getJSONErrorMessage(error); diff --git a/src/utils/forisUrls.js b/src/utils/forisUrls.js index 6f0c777..341d1c1 100644 --- a/src/utils/forisUrls.js +++ b/src/utils/forisUrls.js @@ -9,8 +9,8 @@ export const REFORIS_URL_PREFIX = "/reforis"; export const REFORIS_API_URL_PREFIX = `${REFORIS_URL_PREFIX}/api`; export const ForisURLs = { - login: `${REFORIS_URL_PREFIX}/login`, - logout: `${REFORIS_URL_PREFIX}/logout`, + login: `/login?${REFORIS_URL_PREFIX}/`, + logout: `/logout`, static: `${REFORIS_URL_PREFIX}/static/reforis`, wifi: `${REFORIS_URL_PREFIX}/network-settings/wifi`, diff --git a/src/webSockets/WebSockets.js b/src/webSockets/WebSockets.js index a815656..a89ffa9 100644 --- a/src/webSockets/WebSockets.js +++ b/src/webSockets/WebSockets.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * Copyright (C) 2020-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/) * * This is free software, licensed under the GNU General Public License v3. * See /LICENSE for more information. @@ -7,8 +7,6 @@ /* eslint no-console: "off" */ -import { ForisURLs } from "../utils/forisUrls"; - const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss"; const URL = process.env.LIGHTTPD @@ -21,12 +19,6 @@ export class WebSockets { constructor() { this.ws = new WebSocket(URL); this.ws.onerror = (e) => { - if (!window.initialData.logged) { - console.error( - "WS: Error observed, you aren't logged probably." - ); - window.location.replace(ForisURLs.login); - } console.error("WS: Error:", e); }; this.ws.onmessage = (e) => { From c2eda339980c477dc0dc60cc9527683abd4acd3a Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Wed, 15 Dec 2021 19:05:26 +0300 Subject: [PATCH 2/3] NPM audit fix --- package-lock.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21b1a56..c5d43f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11889,9 +11889,9 @@ "dev": true }, "node_modules/json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", "dev": true }, "node_modules/json-schema-traverse": { @@ -11943,18 +11943,18 @@ } }, "node_modules/jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dev": true, - "engines": [ - "node >=0.6.0" - ], "dependencies": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", - "json-schema": "0.2.3", + "json-schema": "0.4.0", "verror": "1.10.0" + }, + "engines": { + "node": ">=0.6.0" } }, "node_modules/jss": { @@ -32733,9 +32733,9 @@ "dev": true }, "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", "dev": true }, "json-schema-traverse": { @@ -32778,14 +32778,14 @@ "dev": true }, "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dev": true, "requires": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", - "json-schema": "0.2.3", + "json-schema": "0.4.0", "verror": "1.10.0" } }, From 579ed5ea8c6e92f8756e8c740e5b59e4f9435242 Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Wed, 15 Dec 2021 19:05:53 +0300 Subject: [PATCH 3/3] Bump v5.2.0 * Remove login page * NPM audit fix --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c5d43f0..25ef9ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "foris", - "version": "5.1.16", + "version": "5.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "foris", - "version": "5.1.16", + "version": "5.2.0", "license": "GPL-3.0", "dependencies": { "axios": "^0.21.1", diff --git a/package.json b/package.json index 305e230..80b78ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foris", - "version": "5.1.16", + "version": "5.2.0", "description": "Set of components and utils for Foris and its plugins.", "author": "CZ.NIC, z.s.p.o.", "repository": {