Make sidebar logout button trigger SSR reload

This commit is contained in:
Marshall Polaris 2022-07-21 01:32:20 -07:00
parent e84088ba75
commit 1e8bf2433f
2 changed files with 11 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import {
} from '@heroicons/react/outline'
import clsx from 'clsx'
import Link from 'next/link'
import { useRouter } from 'next/router'
import Router, { useRouter } from 'next/router'
import { usePrivateUser, useUser } from 'web/hooks/use-user'
import { firebaseLogout, User } from 'web/lib/firebase/users'
import { ManifoldLogo } from './manifold-logo'
@ -31,6 +31,13 @@ import { setNotificationsAsSeen } from 'web/pages/notifications'
import { PrivateUser } from 'common/user'
import { useWindowSize } from 'web/hooks/use-window-size'
const logout = async () => {
// log out, and then reload the page, in case SSR wants to boot them out
// of whatever logged-in-only area of the site they might be in
await withTracking(firebaseLogout, 'sign out')()
await Router.replace(Router.asPath)
}
function getNavigation() {
return [
{ name: 'Home', href: '/home', icon: HomeIcon },
@ -71,7 +78,7 @@ function getMoreNavigation(user?: User | null) {
{
name: 'Sign out',
href: '#',
onClick: withTracking(firebaseLogout, 'sign out'),
onClick: logout,
},
]
}
@ -122,7 +129,7 @@ function getMoreMobileNav() {
{
name: 'Sign out',
href: '#',
onClick: withTracking(firebaseLogout, 'sign out'),
onClick: logout,
},
]
}

View File

@ -179,7 +179,7 @@ export async function firebaseLogin() {
}
export async function firebaseLogout() {
auth.signOut()
await auth.signOut()
}
const storage = getStorage(app)