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