No session available immediately after successful passkey verification
I am trying to implement passkey authentication.
When I have a successful response from
/api/auth/passkey/verify-authentication
I use the NextJS router to navigate from /login
to /
I also have middleware.ts
checking for sessions, and redirecting to /login
if there is no current session.
Right after the passkey verify API endpoint is successfully called I would assume that I have a valid session, however it seems like I must wait an unknown period before the session is ready?
Observed:
- User gets sucessful response from /api/auth/passkey/verify-authentication
- app client side redirects to /
- middleware checks session, find no session and redirects to /login
- user sees the same /login
page with no apparent
- user manually navigates to /
successfully via url search bar
Expected:
- User gets sucessful response from /api/auth/passkey/verify-authentication
- app client side redirects to /
- middleware checks session, there is a valid session and allows navigation to /
1 Reply
I was having the same issue, looks like the docs need to be updated @Ping. This is what ended up working for me in svelte:
I'm using JS native redirect to refresh and thereby invalidate any state so the user account appears in my nav, but you could invalidate that data more precisely.