[GH-ISSUE #348] fix: two-factor unverified sessions shouldn't appear as active sessions #25552

Closed
opened 2026-04-17 15:49:22 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @0xPratikPatil on GitHub (Oct 26, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/348

Describe the bug
I am using the same code for my project and was using version 0.5.4-beta.6. I just updated the package to 0.6.0 and changed the auth middleware throughout my code, and this is causing the error.

Screenshots
Screenshot from 2024-10-26 23-50-36

Originally created by @0xPratikPatil on GitHub (Oct 26, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/348 **Describe the bug** I am using the same code for my project and was using version 0.5.4-beta.6. I just updated the package to 0.6.0 and changed the auth middleware throughout my code, and this is causing the error. **Screenshots** ![Screenshot from 2024-10-26 23-50-36](https://github.com/user-attachments/assets/dbec54ba-f143-46ab-ac93-36c5549107ef)
GiteaMirror added the lockedbug labels 2026-04-17 15:49:22 -05:00
Author
Owner

@Bekacru commented on GitHub (Oct 26, 2024):

the docs just got updated. you'll need to make a fetch call directly instead of using the authClient

https://www.better-auth.com/docs/integrations/next#middleware

<!-- gh-comment-id:2439722510 --> @Bekacru commented on GitHub (Oct 26, 2024): the docs just got updated. you'll need to make a fetch call directly instead of using the authClient https://www.better-auth.com/docs/integrations/next#middleware
Author
Owner

@0xPratikPatil commented on GitHub (Oct 27, 2024):

The problem is solved now, thank you.

I have one question:
For users using two-factor authentication, if someone enters the correct credentials but cannot bypass the 2FA, a session is generated by the login function but not returned to the user until they enter the correct code. During this time, we see the active session, but it's not in use since the threat actor failed to bypass 2FA. What happens to that session.It must be deleted after some time? otherwise, it will unnecessarily appear in active sessions until it expires. We can show that in the user's activity but not a active session

<!-- gh-comment-id:2439999184 --> @0xPratikPatil commented on GitHub (Oct 27, 2024): The problem is solved now, thank you. I have one question: For users using two-factor authentication, if someone enters the correct credentials but cannot bypass the 2FA, a session is generated by the login function but not returned to the user until they enter the correct code. During this time, we see the active session, but it's not in use since the threat actor failed to bypass 2FA. What happens to that session.It must be deleted after some time? otherwise, it will unnecessarily appear in active sessions until it expires. We can show that in the user's activity but not a active session
Author
Owner

@0xPratikPatil commented on GitHub (Nov 1, 2024):

@Bekacru

<!-- gh-comment-id:2451352356 --> @0xPratikPatil commented on GitHub (Nov 1, 2024): @Bekacru
Author
Owner

@Bekacru commented on GitHub (Nov 1, 2024):

Yeah valid concern. Maybe we should isActive property for session.

<!-- gh-comment-id:2451367167 --> @Bekacru commented on GitHub (Nov 1, 2024): Yeah valid concern. Maybe we should `isActive` property for session.
Author
Owner

@0xPratikPatil commented on GitHub (Nov 3, 2024):

Yes, sir, I'm just pointing out the issue.

<!-- gh-comment-id:2453303048 --> @0xPratikPatil commented on GitHub (Nov 3, 2024): Yes, sir, I'm just pointing out the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#25552