mccordryan / firebaseui-react

FirebaseUI rebuilt as a fully functional and customizable React component.
https://fuidemo.vercel.app
15 stars 6 forks source link

Redirect after reset password flow? #20

Closed christiangenco closed 8 months ago

christiangenco commented 8 months ago

After landing on the login page to reset my password, if I have the following hook in place I don't get a chance to reset my password because I'm redirected before I can:

useEffect(() => {
    if (user) router.push("/");
  }, [user]);

Ideally I would pass a function prop to <ReactFirebaseUI /> that runs after I'm logged in and I've done whatever I need to do like password resetting. Something like onSuccessfulLogin?

mccordryan commented 8 months ago

@christiangenco I'm not certain how to work around that hook. Even with a new callback function, a useEffect redirect would still route them once they're signed in, regardless of what's in the callback function. The existing callback function is designed to handle for this, however. If the user signs in with a reset password link, signInSuccessWithAuthResult won't trigger until they've finished resetting their password.

The following should work:

signInSuccessWithAuthResult: () => {
    router.push("/")
}
christiangenco commented 8 months ago

For posterity, that's the config.callbacks.signInSuccessWithAuthResult prop:

<ReactFirebaseUI config={{
  callbacks: {
    signInSuccessWithAuthResult: onSuccess,
  },
}} />