fix(auth): ask for the 5-digit code the API sends
The API sends a 5-digit sign-in code, but the code step drew six cells and its validation wanted six digits, so nobody could sign in or register. The admin panel keeps its 6-digit code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
69a76446d2
commit
5b8b8f4cd4
|
|
@ -11,12 +11,13 @@ import type { FormEvent } from 'react';
|
|||
import { Controller } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { CODE_RULES } from '../../../../../../features/auth';
|
||||
import { formatMobile, translateMessage } from '../../../../../../shared/utils';
|
||||
import { SupportEntry } from '../../../../organisms/support-entry';
|
||||
import type { CodeStepProps } from './types';
|
||||
|
||||
/**
|
||||
* The 6-digit code step of login and registration: the number it went to, the cells, the resend
|
||||
* The 5-digit code step of login and registration: the number it went to, the cells, the resend
|
||||
* wait and the submit button under them. Blocked, the cells and the button rest and the wait
|
||||
* counts to the moment a new code may be asked for; «ویرایش شماره» stays live. Limited (too many
|
||||
* codes in an hour), only the wait is amber: the last code can still be typed.
|
||||
|
|
@ -78,6 +79,7 @@ export function CodeStep({
|
|||
<OtpInput
|
||||
// A new key empties the cells' own state and focuses the first cell again.
|
||||
key={attempt}
|
||||
length={CODE_RULES.length}
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
onChange={(value: string) => {
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ export const AUTH_EVENTS = {
|
|||
export const AUTH_PURPOSES = ['login', 'register'] as const;
|
||||
|
||||
/**
|
||||
* The code rules the pages show. The server owns them (a code lives 10 minutes, the third wrong
|
||||
* The code rules the pages show. The server owns them (5 digits, a code lives 2 minutes, the third wrong
|
||||
* code blocks the number for 10 minutes, at most 5 codes per number in an hour); the 2-minute
|
||||
* resend wait is the product's, longer than the server's 60-second cooldown.
|
||||
* resend opens when the code runs out.
|
||||
*/
|
||||
export const CODE_RULES = {
|
||||
length: 6,
|
||||
length: 5,
|
||||
resendWaitSeconds: 120,
|
||||
maxMisses: 3,
|
||||
blockSeconds: 600,
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
},
|
||||
"code": {
|
||||
"title": "کد تأیید را وارد کنید",
|
||||
"description": "کد 6 رقمی ارسالشده به {{phone}} را وارد کنید.",
|
||||
"label": "کد تأیید 6 رقمی",
|
||||
"description": "کد 5 رقمی ارسالشده به {{phone}} را وارد کنید.",
|
||||
"label": "کد تأیید 5 رقمی",
|
||||
"edit-phone": "ویرایش شماره",
|
||||
"wrong": "کد واردشده اشتباه است. لطفاً دوباره تلاش کنید.",
|
||||
"wrong-last": "کد واردشده اشتباه است. یک تلاش دیگر باقی مانده است.",
|
||||
|
|
@ -297,7 +297,7 @@
|
|||
},
|
||||
"validation": {
|
||||
"phone-invalid": "شماره موبایل واردشده معتبر نیست.",
|
||||
"code-length": "کد 6 رقمی را کامل وارد کنید.",
|
||||
"code-length": "کد 5 رقمی را کامل وارد کنید.",
|
||||
"role-required": "نوع حساب را انتخاب کنید.",
|
||||
"required": "این فیلد الزامی است.",
|
||||
"first-name-persian": "لطفاً نام را به فارسی وارد کنید.",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export const ID_CARD_SIDES = [
|
|||
|
||||
export const ACCOUNT_TYPES = ['investor', 'creator'] as const;
|
||||
|
||||
export const CODE_PATTERN = /^\d{6}$/;
|
||||
export const CODE_PATTERN = /^\d{5}$/;
|
||||
|
||||
/** The server's creator profile rules (`CREATOR_PROFILE_LIMITS`), so forms reject what the API would. */
|
||||
export const PROFILE_LIMITS = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue