convex auth - getting logged out after 1 day
Hi guys,
I'm using OTP, often overnight when I get back to my app I can't fetch anything and get this message(see image).
I'm also listening to isAuthenticated at the root of my app:
const { isAuthenticated, isLoading } = useConvexAuth();
But it still logs out that I'm indeed authenticated. After one refresh of the page I get logged out. I also tried the <Authenticated/> <Unauthenticated/> components but having the same result.
So, two questions:
- Why am I getting logged out? Using vite.
- Why is the isAuthenticated not updating without a page refresh
4 Replies
watching
It might have to do with the default session duration? Seems like it should default to 30 days however, as per the docs: https://labs.convex.dev/auth/api_reference/server#sessiontotaldurationms
Check out your
authSessions
table in the dashboard and calculate the difference between _creationTime
and expirationTime
, this should correspond to how much time elapses before users are automatically logged out.
You can control the session duration in your auth.ts
file like so (shown with Password
provider, adapt to your situation)
I don't know why the isAuthenticated
thing is behaving strangely though!!server - Convex Auth
Authentication library for your Convex backend
Sounds unexpected! Do you see anything interesting in the network tab of your browser dev tools or in Convex logs? That first error indicates that the Convex Auth library was unable to call some of its functions
Thank you guys 🙏 , I was on a older auth version, seems to work better with the latest(at least I was not logged out after 24h), the expirationTime looks correct as well.