Reauthenticate triggering a full page reload

Hi there! I’m running into a rather odd problem with supabase auth/redwood.

I am building a page that is visible as both an authenticated user and a non-authenticated user. Non-authenticated users have the ability to log themselves in via one time passcode from Supabase on this page.

For non-auth’d users, the flow is:

  • fill out a form in a modal
  • send verification email (via client.auth.signInWithOtp)
  • verify email (via client.auth.verifyOtp)
  • submit original form (must be auth’d, this is where the issue is)

After verifying the OTP, I am technically logged in with Supabase, but not with Redwood/useAuth. To trigger a refresh of this state, I call reauthenticate() from useAuth. It successfully triggers the refresh of currentUser, but the entire page reloads and loses any page state that the user had.

So my question is this: is a page reload expected on the reauthenticate call? Is there anyway to avoid this?

I suspect it could have something to do with the Redwood Router remounting when currentUser is changed? That’s just a shot in the dark though. Any insight would be great!

HI @n1tsua,

Your intuition seems correct to me, and thank you for providing the steps to reproduce!

It seems to me this is another facet of this issue here: [Bug?]: url search parameter is erased if originated from outside the app (via redirection) · Issue #9816 · redwoodjs/redwood · GitHub

Its not clear to me what the solution would be but possiblly… we could check for certain query parameters to be present before we do window.replaceState - we seem to do something similar for auth0 here

@dthyresson what do you think?