sbr
04/04/2022, 4:30 AMauth-helpers
for NextJS and not sure if my issue is a bug or expected behavior.
The app is a simple todo list with authentication. But once I'm signed-in and if I sign out in another tab, I'm still able to write to the table by creating new todos in the first tab. Is this expected?Needle
04/04/2022, 4:30 AM/title
command!
We have solved your problem?
Click the button below to archive it.Needle
04/04/2022, 4:31 AMsaeris
04/05/2022, 12:44 AMNeedle
04/05/2022, 12:44 AMsaeris
04/05/2022, 12:46 AMsbr
04/06/2022, 5:24 AMauth-helpers
work. Cookies instead of localstorage is being used to store the credentials so onAuthStateChanged()
doesn't trigger in all pages even when the auth state has changedsbr
04/06/2022, 5:27 AMuseUser()
should update when the auth state and hence user object has changed but that doesn't seem to work too https://github.com/supabase-community/supabase-auth-helpers/blob/next/src/nextjs/README.md#client-side-data-fetching-with-rls (related to our other discussion https://discord.com/channels/839993398554656828/960462183706296360/961131783322234890)sbr
04/06/2022, 7:15 AMuseUser()
won't give the updated user object when setUser(user)
is being called in the link you shared?thorwebdev
04/06/2022, 7:27 AMgetUser()
Maybe can you outline what you're trying to do? Might be easier to point you in the right direction then.sbr
04/06/2022, 8:10 AMconst {user, error} = useUser()
- User goes to page "b" and then logs out of the app
My question is, should page "a" refresh/update since we have the useUser()
hook in page "a" and the state would have changed?
I presumed that since setUser(user=null)
gets called on user logout https://github.com/supabase-community/supabase-auth-helpers/blob/next/src/react/components/UserProvider.tsx#L58 and useUser()
gives us the user context https://github.com/supabase-community/supabase-auth-helpers/blob/next/src/react/components/UserProvider.tsx#L115, page "a" should update/refresh when the user logs outsaeris
04/06/2022, 11:39 PMsbr
04/07/2022, 1:15 AMsbr
04/07/2022, 1:15 AMsaeris
04/07/2022, 1:55 AMa
and b
are in separate tabs. Navigating from a
to b
triggers the useUser hook to refetch the session. But there's nothing about what's happening in tab b
that will cause tab a
to re-render, much less trigger a refresh of the useUser hook.
So it's not a bug, the current implementation just isn't built to have the behavior you're expecting out of itthorwebdev
04/07/2022, 4:24 AMthorwebdev
04/07/2022, 4:25 AM