misc: tweak captchas

This commit is contained in:
Xyphyn committed 2023-08-18 17:05:23 -07:00
1 parent adc96c8e26
commit 28ffdc5ed8
1 file changed
+28 -18
+28 -18
View File
@@ -13,6 +13,8 @@
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import type { GetCaptchaResponse } from 'lemmy-js-client' import type { GetCaptchaResponse } from 'lemmy-js-client'
import { import {
ArrowPath,
ExclamationCircle,
ExclamationTriangle, ExclamationTriangle,
Icon, Icon,
QuestionMarkCircle, QuestionMarkCircle,
@@ -148,30 +150,38 @@
{#if captchaRequired} {#if captchaRequired}
<div> <div>
<div class="block my-1 font-bold text-sm">Captcha</div> <div class="block my-1 font-bold text-sm">Captcha</div>
{#await getCaptcha()} <div class="flex flex-col gap-4">
<Spinner width={32} /> {#await getCaptcha()}
{:then} <Spinner width={32} />
{#if captcha?.ok} {:then}
<div class="flex flex-col gap-4"> {#if captcha?.ok}
<img <img
src="data:image/png;base64,{captcha.ok.png}" src="data:image/png;base64,{captcha.ok.png}"
alt="Captcha" alt="Captcha"
class="w-max" class="w-max"
/> />
<audio controls src={captchaAudio} /> <audio controls src={captchaAudio} />
<TextInput {:else}
required <Card cardColor="warning" class="p-3 flex gap-2">
bind:value={verifyCaptcha} <Icon src={QuestionMarkCircle} mini size="24" />
placeholder="i guess i'm a robot" No captcha was returned
/> </Card>
</div> {/if}
{:else} {:catch err}
<div class="flex gap-2"> <Card cardColor="error" class="p-3 flex gap-2">
<Icon src={QuestionMarkCircle} mini size="24" /> <Icon src={ExclamationCircle} mini size="24" />
No captcha was returned :( {err}
</div> </Card>
{/if} {/await}
{/await} <Button on:click={() => getCaptcha()} size="square-md">
<Icon src={ArrowPath} size="16" mini />
</Button>
<TextInput
required
bind:value={verifyCaptcha}
placeholder="i guess i'm a robot"
/>
</div>
</div> </div>
{/if} {/if}
<input type="dn" name="honeypot" bind:value={honeypot} class="hidden" /> <input type="dn" name="honeypot" bind:value={honeypot} class="hidden" />