fix
This commit is contained in:
parent
9e6b5cc2db
commit
b43b77ac12
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@ -24,8 +24,6 @@ export default function App() {
|
||||
{ path: 'catalog', label: "Catalog", userGroup: "AUTH" },
|
||||
{ path: 'readerAction', label: "ReaderAction", userGroup: "USER" },
|
||||
{ path: 'creatorAction', label: "CreatorAction", userGroup: "ADMIN" },
|
||||
{ path: 'creator', label: "Creator", userGroup: "ADMIN" },
|
||||
{ path: 'reader', label: "Reader", userGroup: "ADMIN" },
|
||||
{ path: 'users', label: "Users", userGroup: "ADMIN" }
|
||||
];
|
||||
return (
|
||||
|
@ -2,7 +2,38 @@ import {NavLink, useNavigate} from 'react-router-dom';
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
export default function Header(props) {
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("storage", () => {
|
||||
let token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
getRole(token).then((role) => {
|
||||
if (localStorage.getItem("role") != role) {
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("user");
|
||||
localStorage.removeItem("role");
|
||||
window.dispatchEvent(new Event("storage"));
|
||||
navigate("/catalog");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, [])
|
||||
|
||||
const getRole = async function (token) {
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
};
|
||||
const requestUrl = `http://localhost:8080/who_am_i?token=${token}`;
|
||||
const response = await fetch(requestUrl, requestParams);
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
const logoutButtonOnClick = function () {
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("user");
|
||||
|
@ -10,10 +10,8 @@ export default function ReaderList(props) {
|
||||
props.readers?.map((reader) =>
|
||||
<div key={reader.id} className="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div>
|
||||
<div className="pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
<NavLink className="text-white fs-5 fw-bold pt-3 mb-3"
|
||||
to={`/readeraction?id=${reader.id}`}>Имя пользователя: {reader.readerName}
|
||||
</NavLink>
|
||||
<div className="text-white pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
Имя пользователя: {reader.login}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,36 +3,7 @@ import {useEffect} from "react";
|
||||
|
||||
const PrivateRoutes = (props) => {
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("storage", () => {
|
||||
let token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
getRole(token).then((role) => {
|
||||
if (localStorage.getItem("role") != role) {
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("user");
|
||||
localStorage.removeItem("role");
|
||||
window.dispatchEvent(new Event("storage"));
|
||||
navigate("/catalog");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, [])
|
||||
|
||||
const getRole = async function (token) {
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
};
|
||||
const requestUrl = `http://localhost:8080/who_am_i?token=${token}`;
|
||||
const response = await fetch(requestUrl, requestParams);
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
let isAllowed = false;
|
||||
let userRole = localStorage.getItem("role");
|
||||
|
@ -23,8 +23,6 @@ public class UserDto {
|
||||
this.email = user.getEmail();
|
||||
this.password = user.getPassword();
|
||||
this.role = user.getRole();
|
||||
this.creatortId = user.getCreator().getId();
|
||||
this.readerId = user.getReader().getId();
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
Loading…
Reference in New Issue
Block a user