Skip to content

Commit c22f0e8

Browse files
authored
fix(core): handle reset password case during login (#2750)
1 parent 27174e1 commit c22f0e8

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

.changeset/red-crews-move.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Improved login error handling to display a custom error message when BigCommerce indicates a password reset is required, instead of showing a generic error message.
6+
7+
## What's Fixed
8+
9+
When attempting to log in with an account that requires a password reset, users now see an informative error message: "Password reset required. Please check your email for instructions to reset your password."
10+
11+
**Before**: Generic "something went wrong" error message
12+
**After**: Clear error message explaining the password reset requirement
13+
14+
## Migration
15+
16+
### Step 1: Update Translation Files
17+
18+
Add this translation key to your locale files (e.g., `core/messages/en.json`):
19+
20+
```json
21+
{
22+
"Auth": {
23+
"Login": {
24+
"passwordResetRequired": "Password reset required. Please check your email for instructions to reset your password.",
25+
}
26+
}
27+
}
28+
```
29+
30+
Repeat for all supported locales if you maintain custom translations.
31+
32+
### Step 2: Update Login Server Action
33+
34+
In your login server action (e.g., `core/app/[locale]/(default)/(auth)/login/_actions/login.ts`):
35+
36+
Add the password reset error handling block:
37+
```typescript
38+
if (
39+
error instanceof AuthError &&
40+
error.type === 'CallbackRouteError' &&
41+
error.cause &&
42+
error.cause.err instanceof BigCommerceGQLError &&
43+
error.cause.err.message.includes('Reset password"')
44+
) {
45+
return submission.reply({ formErrors: [t('passwordResetRequired')] });
46+
}
47+
```
48+
49+
This should be placed in your error handling, before the generic "Invalid credentials" check.

core/app/[locale]/(default)/(auth)/login/_actions/login.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ export const login = async (
4343
});
4444
}
4545

46+
if (
47+
error instanceof AuthError &&
48+
error.type === 'CallbackRouteError' &&
49+
error.cause &&
50+
error.cause.err instanceof BigCommerceGQLError &&
51+
error.cause.err.message.includes('Reset password"')
52+
) {
53+
return submission.reply({ formErrors: [t('passwordResetRequired')] });
54+
}
55+
4656
if (
4757
error instanceof AuthError &&
4858
error.type === 'CallbackRouteError' &&

core/messages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"password": "Password",
5555
"invalidCredentials": "Your email address or password is incorrect. Try signing in again or reset your password",
5656
"somethingWentWrong": "Something went wrong. Please try again later.",
57+
"passwordResetRequired": "Password reset required. Please check your email for instructions to reset your password.",
5758
"CreateAccount": {
5859
"title": "New customer?",
5960
"accountBenefits": "Create an account with us and you'll be able to:",

0 commit comments

Comments
 (0)