Remove reForis login page

merge-requests/167/head
Marek Sašek 3 years ago
parent 43cb5bff50
commit a66a2f4708
No known key found for this signature in database
GPG Key ID: 8791897AFCF3602F
  1. 7
      src/api/hooks.js
  2. 5
      src/api/utils.js
  3. 4
      src/utils/forisUrls.js
  4. 10
      src/webSockets/WebSockets.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.

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

@ -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`,

@ -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) => {

Loading…
Cancel
Save