-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Describe the bug
The current behavior updates authentication cookies before executing the onSuccess callback. If the onSuccess function throws an error, the callback route correctly returns an error, but the cookies are still set. This makes the authentication appear successful even though the success logic failed.
To Reproduce
Steps to reproduce the behavior:
- Add an onSuccess function inside handleAuth (in app/callback/route.ts) (for next-authkit-example)
- Inside onSuccess, throw an error.
- Observe that the callback route returns an error, but the authentication cookie is still set.
Expected behavior
The callback route should throw an error (already happening), and the cookies should not be set when onSuccess fails.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows
- Browser: Chrome
- authkit-nextjs version: 2.1.0
- Next.js version: 15.2.3
Additional context
Potential solution: If the onSuccess function throws an error, cookies should not be set.
Metadata
Metadata
Assignees
Labels
No labels