feat: persist email through <RequestOTP /> (#21912)

This pull-request implements a super simple change, essentially when we
fail to login we'd like to persist the `email` used when attempting to
sign-in. This just speeds up the flow rather than having to type the
email in again.
This commit is contained in:
Jake Howell
2026-02-04 21:27:39 +11:00
committed by GitHub
parent ad1cdb3a1c
commit c2d74c8ed7
2 changed files with 12 additions and 2 deletions
@@ -71,7 +71,11 @@ export const PasswordSignInForm: FC<PasswordSignInFormProps> = ({
</Button>
<Link
component={RouterLink}
to="/reset-password"
to={
form.values.email
? `/reset-password?email=${encodeURIComponent(form.values.email)}`
: "/reset-password"
}
css={{
fontSize: 12,
fontWeight: 500,
@@ -8,13 +8,15 @@ import { Spinner } from "components/Spinner/Spinner";
import { Stack } from "components/Stack/Stack";
import type { FC } from "react";
import { useMutation } from "react-query";
import { Link as RouterLink } from "react-router";
import { Link as RouterLink, useSearchParams } from "react-router";
import { getApplicationName } from "utils/appearance";
import { pageTitle } from "utils/page";
const RequestOTPPage: FC = () => {
const applicationName = getApplicationName();
const requestOTPMutation = useMutation(requestOneTimePassword());
const [searchParams] = useSearchParams();
const initialEmail = searchParams.get("email") ?? "";
return (
<>
@@ -30,6 +32,7 @@ const RequestOTPPage: FC = () => {
<RequestOTP
error={requestOTPMutation.error}
isRequesting={requestOTPMutation.isPending}
initialEmail={initialEmail}
onRequest={(email) => {
requestOTPMutation.mutate({ email });
}}
@@ -44,12 +47,14 @@ type RequestOTPProps = {
error: unknown;
onRequest: (email: string) => void;
isRequesting: boolean;
initialEmail: string;
};
const RequestOTP: FC<RequestOTPProps> = ({
error,
onRequest,
isRequesting,
initialEmail,
}) => {
return (
<div css={styles.container}>
@@ -83,6 +88,7 @@ const RequestOTP: FC<RequestOTPProps> = ({
autoFocus
required
fullWidth
defaultValue={initialEmail}
/>
<Stack spacing={1}>