Fix double email_user/confirm
due to language render
Add a persistent (per session) flag to skip any actions sparked by future renders after it has already been authenticated.
This commit is contained in:
parent
fdb5658df6
commit
f0ef92614d
1 changed files with 6 additions and 3 deletions
|
@ -14,12 +14,14 @@ type Props = {
|
||||||
doToast: ({}) => void,
|
doToast: ({}) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let authenticationCompleted = false;
|
||||||
|
|
||||||
function SignInVerifyPage(props: Props) {
|
function SignInVerifyPage(props: Props) {
|
||||||
const {
|
const {
|
||||||
history: { push, location },
|
history: { push, location },
|
||||||
doToast,
|
doToast,
|
||||||
} = props;
|
} = props;
|
||||||
const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false);
|
const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(authenticationCompleted);
|
||||||
const [showCaptchaMessage, setShowCaptchaMessage] = useState(false);
|
const [showCaptchaMessage, setShowCaptchaMessage] = useState(false);
|
||||||
const [captchaLoaded, setCaptchaLoaded] = useState(false);
|
const [captchaLoaded, setCaptchaLoaded] = useState(false);
|
||||||
const urlParams = new URLSearchParams(location.search);
|
const urlParams = new URLSearchParams(location.search);
|
||||||
|
@ -43,10 +45,10 @@ function SignInVerifyPage(props: Props) {
|
||||||
}, [authToken, userSubmittedEmail, verificationToken, doToast, push]);
|
}, [authToken, userSubmittedEmail, verificationToken, doToast, push]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!needsRecaptcha) {
|
if (!needsRecaptcha && !isAuthenticationSuccess) {
|
||||||
verifyUser();
|
verifyUser();
|
||||||
}
|
}
|
||||||
}, [needsRecaptcha]);
|
}, []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
let captchaTimeout;
|
let captchaTimeout;
|
||||||
|
@ -80,6 +82,7 @@ function SignInVerifyPage(props: Props) {
|
||||||
...(captchaValue ? { recaptcha: captchaValue } : {}),
|
...(captchaValue ? { recaptcha: captchaValue } : {}),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
authenticationCompleted = true;
|
||||||
setIsAuthenticationSuccess(true);
|
setIsAuthenticationSuccess(true);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
Loading…
Reference in a new issue