Skip to content

Commit

Permalink
Namespace /reset route to /login/forgot-password (bigcommerce#1410)
Browse files Browse the repository at this point in the history
* Move /reset route to /login/forgot-password

* feat: update translations and link to forgot-password page

* fix: update test

* fix: test

* chore: add changeset

* fix: remove unused route from middleware

---------

Co-authored-by: Jorge Moya <[email protected]>
  • Loading branch information
bookernath and jorgemoya authored Oct 3, 2024
1 parent e77834f commit 53cca82
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-cougars-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": minor
---

Move /reset page to /login/forgot-password in order to reduce top-level routes.
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export const LoginForm = () => {
</FormSubmit>
<Link
className="my-5 inline-flex items-center justify-start font-semibold text-primary hover:text-secondary md:my-0"
href="/reset"
href="/login/forgot-password"
>
{t('Form.resetPassword')}
{t('Form.forgotPassword')}
</Link>
</div>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const resetPassword = async ({
path,
reCaptchaToken,
}: SubmitResetPasswordForm) => {
const t = await getTranslations('Reset');
const t = await getTranslations('Login.ForgotPassword');

try {
const parsedData = ResetPasswordSchema.parse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface FormStatus {
}

const SubmitButton = () => {
const t = useTranslations('Reset.Form');
const t = useTranslations('Login.ForgotPassword.Form');

const { pending } = useFormStatus();

Expand All @@ -52,7 +52,7 @@ const SubmitButton = () => {
};

export const ResetPasswordForm = ({ reCaptchaSettings }: Props) => {
const t = useTranslations('Reset.Form');
const t = useTranslations('Login.ForgotPassword.Form');

const form = useRef<HTMLFormElement>(null);
const [formStatus, setFormStatus] = useState<FormStatus | null>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const ResetPageQuery = graphql(
);

export async function generateMetadata() {
const t = await getTranslations('Reset');
const t = await getTranslations('Login.ForgotPassword');

return {
title: t('title'),
};
}

export default async function Reset() {
const t = await getTranslations('Reset');
const t = await getTranslations('Login.ForgotPassword');

const { data } = await client.fetch({
document: ResetPageQuery,
Expand Down
34 changes: 17 additions & 17 deletions core/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"entePasswordMessage": "Enter your password",
"submitting": "Submitting...",
"logIn": "Log in",
"resetPassword": "Forgot your password?"
"forgotPassword": "Forgot your password?"
},
"CreateAccount": {
"heading": "New customer?",
Expand All @@ -43,6 +43,22 @@
"ordersTracking": "Track new orders",
"wishlists": "Save items to your Wishlist",
"createLink": "Create Account "
},
"ForgotPassword": {
"title": "Forgot password",
"heading": "Forgot password",
"Form": {
"description": "Enter the email associated with your account below. We'll send you instructions to reset your password.",
"emailLabel": "Email",
"emailValidationMessage": "Enter a valid email such as [email protected]",
"recaptchaText": "Pass ReCAPTCHA check",
"confirmResetPassword": "If the email address {email} is linked to an account in our store, we have sent you a password reset email. Please check your inbox and spam folder if you don't see it.",
"submitting": "Submitting...",
"submit": "Reset password"
},
"Errors": {
"error":"Unknown error."
}
}
},
"Register": {
Expand All @@ -60,22 +76,6 @@
"error": "Something went wrong. Please try again later."
}
},
"Reset": {
"title": "Reset password",
"heading": "Reset password",
"Form": {
"description": "Enter the email associated with your account below. We'll send you instructions to reset your password.",
"emailLabel": "Email",
"emailValidationMessage": "Enter a valid email such as [email protected]",
"recaptchaText": "Pass ReCAPTCHA check",
"confirmResetPassword": "If the email address {email} is linked to an account in our store, we have sent you a password reset email. Please check your inbox and spam folder if you don't see it.",
"submitting": "Submitting...",
"submit": "Reset password"
},
"Errors": {
"error":"Unknown error."
}
},
"FacetedGroup": {
"MobileSideNav": {
"filters": "Filters",
Expand Down
2 changes: 1 addition & 1 deletion core/middlewares/with-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { auth } from '~/auth';

import { type MiddlewareFactory } from './compose-middlewares';

const AUTH_PATHS = ['/login/', '/register/', '/reset/', '/change-password/'];
const AUTH_PATHS = ['/login/', '/register/', '/change-password/'];

export const withAuth: MiddlewareFactory = (next) => {
return async (request, event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { expect, test } from '~/tests/fixtures';

const email = faker.internet.email({ provider: 'example.com' });

test('Reset password', async ({ page }) => {
await page.goto('/reset');
test('Forgot password', async ({ page }) => {
await page.goto('/login/forgot-password');

await page.getByRole('heading', { name: 'Reset password' }).waitFor();
await page.getByRole('heading', { name: 'Forgot password' }).waitFor();

await page.getByLabel('Email').fill(email);

Expand Down

0 comments on commit 53cca82

Please sign in to comment.