getUserIdentity returning null, when you refresh the page
I am using Clerk to authorise users. I use the ctx.auth.getUserIdentity() method to get the user information. Everything is going fine until I decide to refresh the page. If I refresh the page, ctx.auth.getUserIdentity() returns null even though the user is definitely authorised.
5 Replies
any chance it's a race condition ala this thread? https://discord.com/channels/1019350475847499849/1200540338566213642/1200540338566213642
I read this thread, but I didn't understand how they solved this problem there
Looks like a race. You have to wait for the server to receive the client authentication. You can do this by wrapping your component in
Authenticated
from convex/react
(or by using useConvexAuth
manually)Same here when I re render it shows me current logged in user, if I refresh it shows undefined. I don't know what's wrong. I used useConvexAuth and it returns false when page is refreshed. I am also using the useUser hook by clerk..
Yeah, useConvexAuth will always show false first. But if you have the auth set up correctly, it should then switch to
true
after the auth provider fetches the token.