Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Await auth request when calling signOut #557

Open
kmjennison opened this issue Sep 22, 2022 · 0 comments
Open

Await auth request when calling signOut #557

kmjennison opened this issue Sep 22, 2022 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kmjennison
Copy link
Contributor

kmjennison commented Sep 22, 2022

The signOut method signs out the user on on the Firebase JS SDK but it does not await the "logout" API request. This can cause unexpected behavior.

From discussion: #556


On our index page I have a top menu which hosts the Sign Out button.
The onClick of Sign Out looks like this.

const router = useRouter()
const signOut = async () => {
    await authUser.signOut()
    router.reload()
  }

I expected this to change my index page context, on the router.reload of the page. But at this time I still the authUser.id being present even after reload.
The page only works correctly when I click a manual refresh on browser.

export const getServerSideProps = withAuthUserTokenSSR()(async context => {
  let isAuthenticated = false
  const authUser = context.AuthUser
  if (authUser.id) {
    console.log(authUser.id)
    isAuthenticated = true
  }
return {
    props: {
      isAuthenticated,
    },
  }
}

How can I reflect the correct logout state to my SSR page for updating the UI for a guest user?

Originally posted by @ahetawal-p in #556

@kmjennison kmjennison added enhancement New feature or request help wanted Extra attention is needed labels Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant