mirror of
https://github.com/ProjectSegfault/website.git
synced 2025-05-31 14:12:04 +05:30
Add captcha to the pubnix registration frontend.
This commit is contained in:
@ -15,9 +15,7 @@ export const actions: Actions = {
|
||||
const BodyTypeSchema = Joi.object({
|
||||
username: Joi.string()
|
||||
.required()
|
||||
.pattern(
|
||||
/^[a-z_][a-z0-9_]{0,20}$/
|
||||
)
|
||||
.pattern(/^[a-z_][a-z0-9_]{0,20}$/)
|
||||
.message("Invalid username ([A-Za-z0-9_])"),
|
||||
email: Joi.string().email().required(),
|
||||
ssh: Joi.string()
|
||||
@ -26,7 +24,10 @@ export const actions: Actions = {
|
||||
/^(ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521) [A-Za-z0-9+/]+[=]{0,3}( [^@]+@[^@]+)?$/
|
||||
)
|
||||
.message("Invalid SSH key"),
|
||||
ip: Joi.string().required().ip()
|
||||
ip: Joi.string().required().ip(),
|
||||
"h-captcha-response": Joi.string().required().messages({
|
||||
"any.only": "Captcha is required."
|
||||
})
|
||||
});
|
||||
|
||||
formData.append("ip", getClientAddress());
|
||||
|
@ -1,7 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { ActionData, PageData } from "./$types";
|
||||
import HCaptcha from "svelte-hcaptcha";
|
||||
export let form: ActionData;
|
||||
export let data: PageData;
|
||||
|
||||
let siteKey = "cb477b1b-6f87-43ee-aa79-71e3302fbb34";
|
||||
//export const hcaptchaSiteKey = env.HCAPTCHA_SITE_KEY;
|
||||
</script>
|
||||
|
||||
<h1>{data.title}</h1>
|
||||
@ -43,6 +47,13 @@
|
||||
rows="5"
|
||||
required
|
||||
/>
|
||||
<div>
|
||||
<label for="h-captcha-response"
|
||||
><HCaptcha sitekey={siteKey} />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{#if form?.success}
|
||||
@ -53,6 +64,10 @@
|
||||
{form.message}
|
||||
{/if}
|
||||
|
||||
<div style="display:block;" >
|
||||
<input type="checkbox" style="display:inline-block;width: 1em;margin-right: 10px;" required><p style="display:inline-block;word-break: break-all;">I agree to the <a href="/legal/tos">Terms of Service</p>.
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="transition-filter duration-200 hover:brightness-75"
|
||||
|
Reference in New Issue
Block a user