Hi all. I was hoping to use this premade Auth component from supabase/ui in order to skip reinventing the wheel on various login/signup/password change/etc forms.
However, after successful authentication, redwood auth is naturally unaware of this and thus currentUser remains null. Is there a way to refresh redwood auth (and trigger all the appropriate component re-rendering) without having to call location.reload()?
I’m using it the following way. Thank you for any input you may have.
Hey @tvo you might be able to something like this to refresh the authentication state.
const { client: supabaseClient, reauthenticate } = useAuth()
useEffect(() => {
const { data: authListener } = supabaseClient.auth.onAuthStateChange((event) => {
// you can look at the event here to determine if you should run it
// for example if (event === 'PASSWORD_RECOVERY')
await reauthenticate()
})
return () => {
authListener.unsubscribe()
}
}, [])