Fix captcha loop issue in registration form (#664)

This commit is contained in:
Ajay Bura 2022-07-08 21:07:14 +05:30
parent ca2627d3cf
commit c9df0be874

View file

@ -97,7 +97,7 @@ function Homeserver({ onChange }) {
if (!hsList?.length > 0 || selectedHs < 0 || selectedHs >= hsList?.length) { if (!hsList?.length > 0 || selectedHs < 0 || selectedHs >= hsList?.length) {
throw new Error(); throw new Error();
} }
setHs({ selected: hsList[selectedHs], list: hsList, allowCustom: allowCustom }); setHs({ selected: hsList[selectedHs], list: hsList, allowCustom });
} catch { } catch {
setHs({ selected: 'matrix.org', list: ['matrix.org'], allowCustom: true }); setHs({ selected: 'matrix.org', list: ['matrix.org'], allowCustom: true });
} }
@ -114,8 +114,14 @@ function Homeserver({ onChange }) {
return ( return (
<> <>
<div className="homeserver-form"> <div className="homeserver-form">
<Input name="homeserver" onChange={handleHsInput} value={hs?.selected} forwardRef={hsRef} label="Homeserver" <Input
disabled={hs === null || !hs.allowCustom} /> name="homeserver"
onChange={handleHsInput}
value={hs?.selected}
forwardRef={hsRef}
label="Homeserver"
disabled={hs === null || !hs.allowCustom}
/>
<ContextMenu <ContextMenu
placement="right" placement="right"
content={(hideMenu) => ( content={(hideMenu) => (
@ -319,6 +325,7 @@ function Register({ registerInfo, loginFlow, baseUrl }) {
if (!isAvail) { if (!isAvail) {
actions.setErrors({ username: 'Username is already taken' }); actions.setErrors({ username: 'Username is already taken' });
actions.setSubmitting(false); actions.setSubmitting(false);
return;
} }
if (isEmail && values.email.length > 0) { if (isEmail && values.email.length > 0) {
const result = await auth.verifyEmail(baseUrl, values.email, clientSecret, 1); const result = await auth.verifyEmail(baseUrl, values.email, clientSecret, 1);