Fix: Upgrade next-auth to fix auth example #830
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SYMPTOM
There is a behavior mismatch when I follow the Chapter 15 Adding Authentication - Updating the login form
For the function
authenticateof/app/lib/actions.ts:When I input the right email and wrong password, it should throw the
CredentialsSigninerror, but acutally it throwsCallbackRouteError. The consequence is, the UI shows error message "Something went wrong." instead of "Invalid credentials.".Reference:
CAUSE
The cause is the package
[email protected].Many
next-authusers report same issue that, they foundnext-auththrowsCallbackRouteErrorinstead ofCredentialsSignin. The issue is narrowed down to[email protected], there is a code change breaks error type contract.Reference:
next-authusers report the error type issue: CallbackRouteError on Credentials when following docs nextauthjs/next-auth#11074[email protected]: fix(errors): do not log authjs message with CredentialsSiginin error nextauthjs/next-auth#11050FIX
The
next-authteam's noticed this issue and fixed it in new version,[email protected]. So we can upgrade to[email protected]to fix the authentication behavior.Reference:
next-authpull request to fix the error type issue: fix(core): revert #11050 nextauthjs/next-auth#11469