client: remove signout() function from useSignedIn

We now use the middleware-implemented /signout route
This commit is contained in:
Max Leiter 2022-04-02 00:46:39 -07:00
parent a1fef656bb
commit 52dc5e41a5
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
2 changed files with 3 additions and 10 deletions

View file

@ -35,7 +35,7 @@ const Header = () => {
const [expanded, setExpanded] = useState<boolean>(false) const [expanded, setExpanded] = useState<boolean>(false)
const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true }) const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true })
const isMobile = useMediaQuery('xs', { match: 'down' }) const isMobile = useMediaQuery('xs', { match: 'down' })
const { signedIn: isSignedIn, signout } = useSignedIn() const { signedIn: isSignedIn } = useSignedIn()
const userData = useUserData(); const userData = useUserData();
const [pages, setPages] = useState<Tab[]>([]) const [pages, setPages] = useState<Tab[]>([])
const { setTheme, resolvedTheme } = useTheme() const { setTheme, resolvedTheme } = useTheme()
@ -93,7 +93,6 @@ const Header = () => {
name: 'sign out', name: 'sign out',
icon: <SignOutIcon />, icon: <SignOutIcon />,
value: 'signout', value: 'signout',
// onClick: signout,
href: '/signout' href: '/signout'
}, },
...defaultPages ...defaultPages

View file

@ -1,6 +1,6 @@
import Cookies from "js-cookie" import Cookies from "js-cookie"
import { useRouter } from "next/router" import { useRouter } from "next/router"
import { useEffect, useState } from "react" import { useEffect } from "react"
import useSharedState from "./use-shared-state" import useSharedState from "./use-shared-state"
const useSignedIn = () => { const useSignedIn = () => {
@ -16,12 +16,6 @@ const useSignedIn = () => {
Cookies.set("drift-token", token) Cookies.set("drift-token", token)
} }
const signout = () => {
setSignedIn(false)
Cookies.remove("drift-token")
router.push("/")
}
useEffect(() => { useEffect(() => {
if (token) { if (token) {
setSignedIn(true) setSignedIn(true)
@ -30,7 +24,7 @@ const useSignedIn = () => {
} }
}, [setSignedIn, token]) }, [setSignedIn, token])
return { signedIn, signin, token, signout } return { signedIn, signin, token }
} }
export default useSignedIn export default useSignedIn