refine
refine copied to clipboard
[BUG] Can't refetch Auth
Describe the bug
My app has another way to authenticate the user outside of the authProvider's login method. After successfully logging in without the authProvider, I try to call refetch() from useAuthenticated() and then list('tasks'), but I get redirected to the login page despite the refetch() executing successfully.
Steps To Reproduce
- login w/o the authProvider
- call
useAuthenticated().refetch() - call `list('tasks')
Expected behavior
The user is taken to the List Tasks page, however they are taken to the login page.
Screenshot
No response
Desktop
No response
Mobile
No response
Additional Context
Link to discord thread: https://discord.com/channels/837692625737613362/1043053352486977577/1043053352486977577
Hey @stnguyen90,
authProvider's login, register and logout functions invalidates the auth stores for your application. When you authenticate outside of the authProvider, you must manually invalidate the auth store like this.
Because, the routerProvider calls the useAuthenticated with a different queryKey to prevent the loop in some cases. So you need to invalidate it for the routerProvider to know if you are auth.
Our suggestion for your case is to use the authProvider's register and the useRegister hook. We will discuss the issue with the team again, maybe we will make changes to the codebase, stay tuned 🙏🏻