Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump next-auth #491

Merged
merged 2 commits into from
Nov 29, 2023
Merged

chore: bump next-auth #491

merged 2 commits into from
Nov 29, 2023

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Nov 28, 2023

This PR bumps NextAuth.js to the latest version.

The main noticeable change is cleaner error handling: Whenever a NextAuth.js-induced error happens in a Server Action, we now throw an AuthError instance that makes error handling a bit easier.

In addition, this new release includes bug fixes. See the release notes: https://github.com/nextauthjs/next-auth/releases/tag/next-auth%405.0.0-beta.4

Slack thread

Copy link

vercel bot commented Nov 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-learn-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 1:54pm
next-learn-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 1:54pm
next-seo-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 1:54pm

Comment on lines +130 to +136
if (error instanceof AuthError) {
switch (error.type) {
case 'CredentialsSignin':
return 'Invalid credentials.';
default:
return 'Something went wrong.';
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a return type outside of this condition (or in an else) to catch when error instanceof AuthError returns false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those errors are thrown further down. It's not the task of the authenticate method. There are special throws as well that powers redirect() (used internally by signIn) which should not be handled and let Next.js/React handle them with their error boundaries.

If the error is an AuthError, we already know how to handle it.

@delbaoliveira delbaoliveira merged commit e75f714 into main Nov 29, 2023
6 checks passed
@delbaoliveira delbaoliveira deleted the chore/upgrade-next-auth branch November 29, 2023 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants