Fix logout and add context support
This commit is contained in:
parent
b0fca8138c
commit
dcfa961a3f
1 changed files with 8 additions and 3 deletions
|
|
@ -12,7 +12,7 @@ import './index.scss'
|
||||||
interface Props {}
|
interface Props {}
|
||||||
|
|
||||||
const Header = (props: Props) => {
|
const Header = (props: Props) => {
|
||||||
const { editable } = useContext(AppContext)
|
const { editable, setEditable, setAuthenticated } = useContext(AppContext)
|
||||||
|
|
||||||
const [username, setUsername] = useState(undefined)
|
const [username, setUsername] = useState(undefined)
|
||||||
const [cookies, _, removeCookie] = useCookies(['user'])
|
const [cookies, _, removeCookie] = useCookies(['user'])
|
||||||
|
|
@ -45,8 +45,13 @@ const Header = (props: Props) => {
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
removeCookie('user')
|
removeCookie('user')
|
||||||
window.history.replaceState(null, `Grid Tool`, `/`)
|
|
||||||
// navigate(0)
|
setAuthenticated(false)
|
||||||
|
if (editable) setEditable(false)
|
||||||
|
|
||||||
|
// How can we log out without navigating to root
|
||||||
|
router.push('/')
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue