Skip to content

Commit

Permalink
Merge pull request #17969 from mozilla/2fa-backup-keyboard
Browse files Browse the repository at this point in the history
fix(2fa): Show text keyboard on inline_totp_setup recovery code confirmation
  • Loading branch information
LZoog authored Nov 4, 2024
2 parents e4a0a37 + 77537c0 commit 47ca7c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions packages/fxa-settings/src/components/FormVerifyCode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export enum InputModeEnum {
numeric = 'numeric',
}

export const commonBackupCodeFormAttributes = {
inputMode: InputModeEnum.text,
pattern: '[a-zA-Z0-9]',
maxLength: 10,
};

export type FormAttributes = {
inputLabelText: string;
inputFtlId: string;
Expand Down
7 changes: 4 additions & 3 deletions packages/fxa-settings/src/pages/InlineRecoverySetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import CardHeader from '../../components/CardHeader';
import AppLayout from '../../components/AppLayout';
import Banner, { BannerType } from '../../components/Banner';
import { copyRecoveryCodes } from '../../lib/totp';
import FormVerifyCode from '../../components/FormVerifyCode';
import FormVerifyCode, {
commonBackupCodeFormAttributes,
} from '../../components/FormVerifyCode';
import { AuthUiErrors } from '../../lib/auth-errors/auth-errors';
import { InlineRecoverySetupProps } from './interfaces';
import { getErrorFtlId, getLocalizedErrorMessage } from '../../lib/error-utils';
Expand Down Expand Up @@ -159,8 +161,7 @@ const InlineRecoverySetup = ({
inputFtlId: 'inline-recovery-backup-authentication-code',
submitButtonText: 'Confirm',
submitButtonFtlId: 'inline-recovery-confirm-button',
pattern: '\\w{10}',
maxLength: 10,
...commonBackupCodeFormAttributes,
}}
codeErrorMessage={recoveryCodeError}
setCodeErrorMessage={setRecoveryCodeError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { useFtlMsgResolver } from '../../../models';
import { FtlMsg, hardNavigate } from 'fxa-react/lib/utils';
import protectionShieldIcon from '@fxa/shared/assets/images/protection-shield.svg';
import FormVerifyCode, {
commonBackupCodeFormAttributes,
FormAttributes,
InputModeEnum,
} from '../../../components/FormVerifyCode';

export type ConfirmTotpResetPasswordProps = {
Expand Down Expand Up @@ -40,11 +40,9 @@ const ConfirmTotpResetPassword = ({
const recoveryCodeFormAttributes: FormAttributes = {
inputFtlId: 'confirm-recovery-code-reset-password-input-label',
inputLabelText: 'Enter 10-digit backup authentication code',
inputMode: InputModeEnum.text,
pattern: '[a-zA-Z0-9]',
maxLength: 10,
submitButtonFtlId: 'confirm-totp-reset-password-confirm-button',
submitButtonText: 'Confirm',
...commonBackupCodeFormAttributes,
};

const localizedCustomCodeRequiredMessage = ftlMsgResolver.getMsg(
Expand Down

0 comments on commit 47ca7c4

Please sign in to comment.