Skip to content

Commit 16d556c

Browse files
Ensure captcha verification code gets submitted in signup request (#5010)
Co-authored-by: Eric Bailey <[email protected]>
1 parent 94d2180 commit 16d556c

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/screens/Signup/StepCaptcha/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ export function StepCaptcha() {
4141
(code: string) => {
4242
setCompleted(true)
4343
logEvent('signup:captchaSuccess', {})
44-
const submitTask = {code, mutableProcessed: false}
4544
dispatch({
4645
type: 'submit',
47-
task: submitTask,
46+
task: {verificationCode: code, mutableProcessed: false},
4847
})
4948
},
5049
[dispatch],

src/screens/Signup/StepHandle.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ export function StepHandle() {
6565
})
6666
// phoneVerificationRequired is actually whether a captcha is required
6767
if (!state.serviceDescription?.phoneVerificationRequired) {
68-
const submitTask = {code: undefined, mutableProcessed: false}
69-
dispatch({type: 'submit', task: submitTask})
68+
dispatch({
69+
type: 'submit',
70+
task: {verificationCode: undefined, mutableProcessed: false},
71+
})
7072
return
7173
}
7274
dispatch({type: 'next'})

src/screens/Signup/state.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export enum SignupStep {
2727
}
2828

2929
type SubmitTask = {
30-
code: string | undefined
30+
verificationCode: string | undefined
3131
mutableProcessed: boolean // OK to mutate assuming it's never read in render.
3232
}
3333

@@ -62,7 +62,6 @@ export type SignupAction =
6262
| {type: 'setDateOfBirth'; value: Date}
6363
| {type: 'setInviteCode'; value: string}
6464
| {type: 'setHandle'; value: string}
65-
| {type: 'setVerificationCode'; value: string}
6665
| {type: 'setError'; value: string}
6766
| {type: 'setIsLoading'; value: boolean}
6867
| {type: 'submit'; task: SubmitTask}
@@ -189,11 +188,7 @@ export function useSubmitSignup() {
189188
const onboardingDispatch = useOnboardingDispatch()
190189

191190
return useCallback(
192-
async (
193-
state: SignupState,
194-
dispatch: (action: SignupAction) => void,
195-
verificationCode?: string,
196-
) => {
191+
async (state: SignupState, dispatch: (action: SignupAction) => void) => {
197192
if (!state.email) {
198193
dispatch({type: 'setStep', value: SignupStep.INFO})
199194
return dispatch({
@@ -224,7 +219,7 @@ export function useSubmitSignup() {
224219
}
225220
if (
226221
state.serviceDescription?.phoneVerificationRequired &&
227-
!verificationCode
222+
!state.pendingSubmit?.verificationCode
228223
) {
229224
dispatch({type: 'setStep', value: SignupStep.CAPTCHA})
230225
logger.error('Signup Flow Error', {
@@ -247,7 +242,7 @@ export function useSubmitSignup() {
247242
password: state.password,
248243
birthDate: state.dateOfBirth,
249244
inviteCode: state.inviteCode.trim(),
250-
verificationCode: verificationCode,
245+
verificationCode: state.pendingSubmit?.verificationCode,
251246
})
252247
/*
253248
* Must happen last so that if the user has multiple tabs open and

0 commit comments

Comments
 (0)