Ensure captcha verification code gets submitted in signup request (#5010)
Co-authored-by: Eric Bailey <git@esb.lol>zio/stable
parent
94d2180aaa
commit
16d556c3c9
|
@ -41,10 +41,9 @@ export function StepCaptcha() {
|
||||||
(code: string) => {
|
(code: string) => {
|
||||||
setCompleted(true)
|
setCompleted(true)
|
||||||
logEvent('signup:captchaSuccess', {})
|
logEvent('signup:captchaSuccess', {})
|
||||||
const submitTask = {code, mutableProcessed: false}
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
task: submitTask,
|
task: {verificationCode: code, mutableProcessed: false},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[dispatch],
|
[dispatch],
|
||||||
|
|
|
@ -65,8 +65,10 @@ export function StepHandle() {
|
||||||
})
|
})
|
||||||
// phoneVerificationRequired is actually whether a captcha is required
|
// phoneVerificationRequired is actually whether a captcha is required
|
||||||
if (!state.serviceDescription?.phoneVerificationRequired) {
|
if (!state.serviceDescription?.phoneVerificationRequired) {
|
||||||
const submitTask = {code: undefined, mutableProcessed: false}
|
dispatch({
|
||||||
dispatch({type: 'submit', task: submitTask})
|
type: 'submit',
|
||||||
|
task: {verificationCode: undefined, mutableProcessed: false},
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dispatch({type: 'next'})
|
dispatch({type: 'next'})
|
||||||
|
|
|
@ -27,7 +27,7 @@ export enum SignupStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubmitTask = {
|
type SubmitTask = {
|
||||||
code: string | undefined
|
verificationCode: string | undefined
|
||||||
mutableProcessed: boolean // OK to mutate assuming it's never read in render.
|
mutableProcessed: boolean // OK to mutate assuming it's never read in render.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,6 @@ export type SignupAction =
|
||||||
| {type: 'setDateOfBirth'; value: Date}
|
| {type: 'setDateOfBirth'; value: Date}
|
||||||
| {type: 'setInviteCode'; value: string}
|
| {type: 'setInviteCode'; value: string}
|
||||||
| {type: 'setHandle'; value: string}
|
| {type: 'setHandle'; value: string}
|
||||||
| {type: 'setVerificationCode'; value: string}
|
|
||||||
| {type: 'setError'; value: string}
|
| {type: 'setError'; value: string}
|
||||||
| {type: 'setIsLoading'; value: boolean}
|
| {type: 'setIsLoading'; value: boolean}
|
||||||
| {type: 'submit'; task: SubmitTask}
|
| {type: 'submit'; task: SubmitTask}
|
||||||
|
@ -189,11 +188,7 @@ export function useSubmitSignup() {
|
||||||
const onboardingDispatch = useOnboardingDispatch()
|
const onboardingDispatch = useOnboardingDispatch()
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
async (
|
async (state: SignupState, dispatch: (action: SignupAction) => void) => {
|
||||||
state: SignupState,
|
|
||||||
dispatch: (action: SignupAction) => void,
|
|
||||||
verificationCode?: string,
|
|
||||||
) => {
|
|
||||||
if (!state.email) {
|
if (!state.email) {
|
||||||
dispatch({type: 'setStep', value: SignupStep.INFO})
|
dispatch({type: 'setStep', value: SignupStep.INFO})
|
||||||
return dispatch({
|
return dispatch({
|
||||||
|
@ -224,7 +219,7 @@ export function useSubmitSignup() {
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
state.serviceDescription?.phoneVerificationRequired &&
|
state.serviceDescription?.phoneVerificationRequired &&
|
||||||
!verificationCode
|
!state.pendingSubmit?.verificationCode
|
||||||
) {
|
) {
|
||||||
dispatch({type: 'setStep', value: SignupStep.CAPTCHA})
|
dispatch({type: 'setStep', value: SignupStep.CAPTCHA})
|
||||||
logger.error('Signup Flow Error', {
|
logger.error('Signup Flow Error', {
|
||||||
|
@ -247,7 +242,7 @@ export function useSubmitSignup() {
|
||||||
password: state.password,
|
password: state.password,
|
||||||
birthDate: state.dateOfBirth,
|
birthDate: state.dateOfBirth,
|
||||||
inviteCode: state.inviteCode.trim(),
|
inviteCode: state.inviteCode.trim(),
|
||||||
verificationCode: verificationCode,
|
verificationCode: state.pendingSubmit?.verificationCode,
|
||||||
})
|
})
|
||||||
/*
|
/*
|
||||||
* Must happen last so that if the user has multiple tabs open and
|
* Must happen last so that if the user has multiple tabs open and
|
||||||
|
|
Loading…
Reference in New Issue