client: fix logging out with new cookie auth

This commit is contained in:
Max Leiter 2022-03-20 22:34:42 -07:00
parent 3f8511e0c1
commit c57e0d6692
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
2 changed files with 4 additions and 2 deletions

View file

@ -80,7 +80,6 @@ const Post = () => {
else setDocs([...docs, ...files]) else setDocs([...docs, ...files])
}, [docs, title]) }, [docs, title])
return ( return (
<div> <div>
<Title title={title} setTitle={setTitle} /> <Title title={title} setTitle={setTitle} />

View file

@ -6,7 +6,10 @@ import Cookies from 'js-cookie'
const useSignedIn = ({ redirectIfNotAuthed = false }: { redirectIfNotAuthed?: boolean }) => { const useSignedIn = ({ redirectIfNotAuthed = false }: { redirectIfNotAuthed?: boolean }) => {
const [isSignedIn, setSignedIn] = useSharedState('isSignedIn', false) const [isSignedIn, setSignedIn] = useSharedState('isSignedIn', false)
const [isLoading, setLoading] = useSharedState('isLoading', true) const [isLoading, setLoading] = useSharedState('isLoading', true)
const signout = useCallback(() => setSignedIn(false), [setSignedIn]) const signout = useCallback(() => {
Cookies.remove('drift-token')
setSignedIn(false)
}, [setSignedIn])
const router = useRouter(); const router = useRouter();
if (redirectIfNotAuthed && !isLoading && isSignedIn === false) { if (redirectIfNotAuthed && !isLoading && isSignedIn === false) {