Hello,
I have a dynamic navbar on my app that uses graphql to fetch the links to be displayed from the api side. However, this seems to prevent users from logging in strangely enough.
note timings
When the graphql query is removed, the login is successful. However, when I add the component using the query to the page, the second (2) auth?method=getToken
request fires prematurely, resetting the cookies right after they are set by the first (1) POST
request.
The query doesn’t require auth (@skipAuth
) so I am not sure why it is interacting with the auth api. The component does not call the useAuth
hook either.
Not sure if this is a bug or misconfig on my part.
1 Like
Hi. DbAuth requires a call to a serverless function outside graphql to set the cookie and auth state.
You might try the Router | RedwoodJS Docs
Loader while auth details are being retrieved
Let’s say you have a dashboard area on your Redwood app, which can only be accessed after logging in. When Redwood Router renders your private page, it will first fetch the user’s details, and only render the page if it determines the user is indeed logged in.
In order to display a loader while auth details are being retrieved you can add the whileLoadingAuth
prop to your PrivateSet
component:
There is also a loading state in the useAuth hook as documented in Authentication | RedwoodJS Docs
Otherwise if you could share a public repo that reproduces this behavior we can try to diagnose and help.
Yep, MRE is in GitHub - Compositr/redwood-race-condition: MRE for dbAuth & GraphQL
/signup
first, then log out and try logging back in. A very basic example cell and GraphQL is included on only the login page to induce the behaviour.