Commit ffeb1b24 by Wod Committed by GitHub

fix(web): refresh Turnstile token after login attempt (#6764)

Co-authored-by: multica-agent <github@multica.ai>
parent 4eaeefbd
......@@ -72,6 +72,7 @@ export function UserAuthForm({
const [isPasskeyLoading, setIsPasskeyLoading] = useState(false)
const [isWeChatDialogOpen, setIsWeChatDialogOpen] = useState(false)
const [isWeChatSubmitting, setIsWeChatSubmitting] = useState(false)
const [turnstileWidgetKey, setTurnstileWidgetKey] = useState(0)
const legalConsentErrorMessage = t('Please agree to the legal terms first')
const loginFailedMessage = t('Login failed')
......@@ -158,12 +159,18 @@ export function UserAuthForm({
if (!validateTurnstile()) return
const submittedTurnstileToken = turnstileToken
if (isTurnstileEnabled) {
setTurnstileToken('')
setTurnstileWidgetKey((current) => current + 1)
}
setIsLoading(true)
try {
const res = await login({
username: data.username,
password: data.password,
turnstile: turnstileToken,
turnstile: submittedTurnstileToken,
})
if (res.success) {
......@@ -408,8 +415,10 @@ export function UserAuthForm({
{isTurnstileEnabled && (
<div className='mt-2'>
<Turnstile
key={turnstileWidgetKey}
siteKey={turnstileSiteKey}
onVerify={setTurnstileToken}
onExpire={() => setTurnstileToken('')}
/>
</div>
)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment