redirect to login page on logout
This commit is contained in:
parent
6c2e0dbe9e
commit
d9a9ecafbb
@ -29,7 +29,9 @@ const SidebarMenu = ({menuItems = [], children}) => {
|
|||||||
return <NavLink className='sidebar-menu-item sidebar-menu-child-item' activeClassName='active' to={to} key={label}>{label}</NavLink>;
|
return <NavLink className='sidebar-menu-item sidebar-menu-child-item' activeClassName='active' to={to} key={label}>{label}</NavLink>;
|
||||||
});
|
});
|
||||||
elements.push(<div key={label} className='parent-menu'>
|
elements.push(<div key={label} className='parent-menu'>
|
||||||
<NavLink className={`sidebar-menu-item ${subElements?.length ? 'has-children' : ''}`} activeClassName='active' {...rest} key={label}>{label}{subElements && <i className="sidebar-menu-item-carrot" onClick={expandMenu}></i>}</NavLink>
|
<NavLink className={`sidebar-menu-item ${subElements?.length ? 'has-children' : ''}`} activeClassName='active' {...rest} key={label}>
|
||||||
|
{label}{subElements && <i className="sidebar-menu-item-carrot" onClick={expandMenu}></i>}
|
||||||
|
</NavLink>
|
||||||
{subElements && <div className='sidebar-menu-child-wrapper'>
|
{subElements && <div className='sidebar-menu-child-wrapper'>
|
||||||
{subElements}
|
{subElements}
|
||||||
</div>}
|
</div>}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { useRef } from "react";
|
import React, { useRef } from "react";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
import '../css/components/UserControls.css';
|
import '../css/components/UserControls.css';
|
||||||
import { useLoginContext } from "../structures/UserContext";
|
import { useLoginContext } from "../structures/UserContext";
|
||||||
import ClickDetector from "../util/ClickDetector";
|
import ClickDetector from "../util/ClickDetector";
|
||||||
@ -8,6 +9,7 @@ const UserControls = () => {
|
|||||||
|
|
||||||
const [user, updateUser] = useLoginContext();
|
const [user, updateUser] = useLoginContext();
|
||||||
const detailsRef = useRef();
|
const detailsRef = useRef();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
@ -16,6 +18,7 @@ const UserControls = () => {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
clearSession();
|
clearSession();
|
||||||
updateUser();
|
updateUser();
|
||||||
|
navigate('/login');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,7 +28,7 @@ const UserControls = () => {
|
|||||||
<details ref={detailsRef} className='dropdown user-controls'>
|
<details ref={detailsRef} className='dropdown user-controls'>
|
||||||
<summary className="is-vertical-align">
|
<summary className="is-vertical-align">
|
||||||
Hello {user.displayName || user.username}
|
Hello {user.displayName || user.username}
|
||||||
<img className="profile-picture" src="https://cdn.discordapp.com/avatars/187613017733726210/ee764860975d78bfd52652c6ddaed47b.webp?size=64"></img>
|
<img className="profile-picture" src={`/api/users/${user.id}/avatar`}></img>
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
Loading…
Reference in New Issue
Block a user