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

fix(core): handle invalid credentials error message in Login #1944

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

jorgemoya
Copy link
Contributor

What/Why?

Properly look for the type of error we get from next-auth and show the correct message when credentials are invalid.

Before

Screenshot 2025-01-30 at 2 37 19 PM

After

Screenshot 2025-01-30 at 3 12 15 PM

@jorgemoya jorgemoya requested a review from a team as a code owner January 30, 2025 21:16
Copy link

changeset-bot bot commented Jan 30, 2025

🦋 Changeset detected

Latest commit: b1d1fa4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 30, 2025

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

Name Status Preview Comments Updated (UTC)
catalyst-canary ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 9:45pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst ⬜️ Ignored (Inspect) Jan 30, 2025 9:45pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 9:45pm
catalyst-soul ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 9:45pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 9:45pm

Comment on lines 46 to 53
if (error instanceof AuthError) {
if (error.name === 'CallbackRouteError') {
if (error.cause && error.cause.err?.message.includes('Invalid credentials')) {
return submission.reply({ formErrors: [t('Form.invalidCredentials')] });
}
}

return submission.reply({ formErrors: [error.name] });
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the nested conditionals?

Suggested change
if (error instanceof AuthError) {
if (error.name === 'CallbackRouteError') {
if (error.cause && error.cause.err?.message.includes('Invalid credentials')) {
return submission.reply({ formErrors: [t('Form.invalidCredentials')] });
}
}
return submission.reply({ formErrors: [error.name] });
if (
error instanceof AuthError &&
error.name === 'CallbackRouteError' &&
error.cause &&
error.cause.err?.message.includes('Invalid credentials')
) {
return submission.reply({ formErrors: [t('Form.invalidCredentials')] });
}
return submission.reply({ formErrors: [error.name] });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@jorgemoya jorgemoya added this pull request to the merge queue Jan 30, 2025
Merged via the queue into canary with commit c5ce9dc Jan 30, 2025
9 checks passed
@jorgemoya jorgemoya deleted the handle-auth-error-login branch January 30, 2025 21:57
@github-actions github-actions bot mentioned this pull request Jan 30, 2025
Copy link
Contributor

⚡️🏠 Lighthouse report

Lighthouse ran against https://catalyst-canary-3b6r1vle1-bigcommerce-platform.vercel.app

🖥️ Desktop

We ran Lighthouse against the changes on a desktop and produced this report. Here's the summary:

Category Score
🟢 Performance 98
🟢 Accessibility 92
🟠 Best practices 78
🟠 SEO 82

📱 Mobile

We ran Lighthouse against the changes on a mobile and produced this report. Here's the summary:

Category Score
🟠 Performance 86
🟢 Accessibility 92
🟠 Best practices 78
🟠 SEO 85

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.

2 participants