Reset cookie pointer on signout
This commit is contained in:
parent
111d5ea610
commit
260c97624b
|
@ -89,6 +89,7 @@ function NotificationBell () {
|
||||||
function NavProfileMenu ({ me, dropNavKey }) {
|
function NavProfileMenu ({ me, dropNavKey }) {
|
||||||
const { registration: swRegistration, togglePushSubscription } = useServiceWorker()
|
const { registration: swRegistration, togglePushSubscription } = useServiceWorker()
|
||||||
const showModal = useShowModal()
|
const showModal = useShowModal()
|
||||||
|
const { resetMultiAuthPointer } = useAccounts()
|
||||||
return (
|
return (
|
||||||
<div className='position-relative'>
|
<div className='position-relative'>
|
||||||
<Dropdown className={styles.dropdown} align='end'>
|
<Dropdown className={styles.dropdown} align='end'>
|
||||||
|
@ -140,6 +141,7 @@ function NavProfileMenu ({ me, dropNavKey }) {
|
||||||
// don't prevent signout because of an unsubscription error
|
// don't prevent signout because of an unsubscription error
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
resetMultiAuthPointer()
|
||||||
await signOut({ callbackUrl: '/' })
|
await signOut({ callbackUrl: '/' })
|
||||||
}}
|
}}
|
||||||
>logout
|
>logout
|
||||||
|
|
|
@ -38,6 +38,10 @@ export const AccountProvider = ({ children }) => {
|
||||||
setAccounts(accounts => accounts.filter(({ id }) => id !== userId))
|
setAccounts(accounts => accounts.filter(({ id }) => id !== userId))
|
||||||
}, [setAccounts])
|
}, [setAccounts])
|
||||||
|
|
||||||
|
const resetMultiAuthPointer = useCallback(() => {
|
||||||
|
document.cookie = 'multi_auth.user-id='
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// document not defined on server
|
// document not defined on server
|
||||||
if (SSR) return
|
if (SSR) return
|
||||||
|
@ -45,7 +49,7 @@ export const AccountProvider = ({ children }) => {
|
||||||
setIsAnon(multiAuthUserIdCookie === 'anonymous')
|
setIsAnon(multiAuthUserIdCookie === 'anonymous')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <AccountContext.Provider value={{ accounts, addAccount, removeAccount, isAnon, setIsAnon }}>{children}</AccountContext.Provider>
|
return <AccountContext.Provider value={{ accounts, addAccount, removeAccount, isAnon, setIsAnon, resetMultiAuthPointer }}>{children}</AccountContext.Provider>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAccounts = () => useContext(AccountContext)
|
export const useAccounts = () => useContext(AccountContext)
|
||||||
|
|
Loading…
Reference in New Issue