Lab 6 осталась фигня с комментариями
This commit is contained in:
parent
3cb5f04ba6
commit
6da86fa98c
@ -16,14 +16,13 @@ export default function App() {
|
||||
{ path: 'news', label: "News", userGroup: "AUTH" },
|
||||
{ path: 'users', label: "Users", userGroup: "ADMIN" },
|
||||
{ path: 'account', label: "Account", userGroup: "AUTH" },
|
||||
{path: 'Post',userGroup: "AUTH"},
|
||||
];
|
||||
return(
|
||||
<>
|
||||
<BrowserRouter>
|
||||
<div className='body_app'>
|
||||
<NavBar links={links}></NavBar>
|
||||
<div className="d-flex text-white bg-info bg-gradient fw-bold ">
|
||||
<div className="d-flex flex-column text-white bg-info bg-gradient fw-bold ">
|
||||
<Routes>
|
||||
<Route element={<LoginPage />} path="/login" />
|
||||
<Route element={<SignupPage />} path="/signup" />
|
||||
|
@ -5,16 +5,22 @@ import Modal from "../common/Modal";
|
||||
|
||||
export default function Catalog(props) {
|
||||
const [items, setItems] = useState([]);
|
||||
const [userId,setUserId] = useState(0);
|
||||
const [userId,setUserId] = useState(-1);
|
||||
const [value,setvalue]=useState('');
|
||||
|
||||
useEffect(() => {
|
||||
loadItems();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("random");
|
||||
}, [items]);
|
||||
|
||||
useEffect(()=>
|
||||
{
|
||||
if(userId==-1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
loadItems1();
|
||||
},[userId])
|
||||
|
||||
@ -23,6 +29,10 @@ export default function Catalog(props) {
|
||||
}
|
||||
useEffect(()=>
|
||||
{
|
||||
if(value=="")
|
||||
{
|
||||
return;
|
||||
}
|
||||
loadItems2();
|
||||
},[value])
|
||||
const setUserIDd = async function(id)
|
||||
@ -39,6 +49,7 @@ export default function Catalog(props) {
|
||||
const requestUrl = `http://localhost:8080/api/1.0/post`;
|
||||
const response = await fetch(requestUrl,requestParams);
|
||||
const posts = await response.json();
|
||||
|
||||
setItems(posts);
|
||||
}
|
||||
const loadItems1 = async function() {
|
||||
@ -64,7 +75,6 @@ export default function Catalog(props) {
|
||||
const requestUrl = `http://localhost:8080/api/1.0/post/filteredposts?Text=${value}`;
|
||||
const response = await fetch(requestUrl,requestParams);
|
||||
const posts = await response.json();
|
||||
console.log(posts);
|
||||
setItems(posts);
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,15 @@ export default function CatalogAccount(props) {
|
||||
const [userId,setUserId]=useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
loadItems();
|
||||
getUserId();
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if(userId==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
loadItems();
|
||||
}, [userId]);
|
||||
|
||||
const getTokenForHeader = function () {
|
||||
return "Bearer " + localStorage.getItem("token");
|
||||
@ -40,6 +46,7 @@ export default function CatalogAccount(props) {
|
||||
"Authorization": getTokenForHeader(),
|
||||
}
|
||||
};
|
||||
console.log(userId);
|
||||
const requestUrl = `http://localhost:8080/api/1.0/user/${userId}/posts`;
|
||||
const response = await fetch(requestUrl,requestParams);
|
||||
const posts = await response.json();
|
||||
|
@ -61,16 +61,9 @@ public class SecurityConfiguration {
|
||||
.and()
|
||||
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.anonymous();
|
||||
return http.build();
|
||||
return http.userDetailsService(userService).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManagerBean(HttpSecurity http) throws Exception {
|
||||
AuthenticationManagerBuilder authenticationManagerBuilder = http
|
||||
.getSharedObject(AuthenticationManagerBuilder.class);
|
||||
authenticationManagerBuilder.userDetailsService(userService);
|
||||
return authenticationManagerBuilder.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||
|
Loading…
Reference in New Issue
Block a user