mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-11-22 16:13:00 +05:30
Add captcha to the pubnix registration frontend.
This commit is contained in:
parent
f98d8d03c9
commit
c9520c82fd
@ -36,6 +36,7 @@
|
||||
"@auth/core": "^0.2.5",
|
||||
"@auth/sveltekit": "^0.1.12",
|
||||
"joi": "^17.7.0",
|
||||
"snarkdown": "^2.0.0"
|
||||
"snarkdown": "^2.0.0",
|
||||
"svelte-hcaptcha": "^0.1.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
lockfileVersion: '6.1'
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
@ -17,6 +17,9 @@ dependencies:
|
||||
snarkdown:
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0
|
||||
svelte-hcaptcha:
|
||||
specifier: ^0.1.1
|
||||
version: 0.1.1
|
||||
|
||||
devDependencies:
|
||||
'@iconify-json/ic':
|
||||
@ -1667,6 +1670,10 @@ packages:
|
||||
resolution: {integrity: sha512-/QmIqWGwzcfE82FAMuHBlKFwudW7Vcos60Ii8j/mJZ0H6kGAXwL5EGlcc8voBJMJv/i0QZmhp5b1ZX/XKg9NJQ==}
|
||||
dev: true
|
||||
|
||||
/svelte-hcaptcha@0.1.1:
|
||||
resolution: {integrity: sha512-iFF3HwfrCRciJnDs4Y9/rpP/BM2U/5zt+vh+9d4tALPAHVkcANiJIKqYuS835pIaTm6gt+xOzjfFI3cgiRI29A==}
|
||||
dev: false
|
||||
|
||||
/svelte-hmr@0.15.1(svelte@3.55.1):
|
||||
resolution: {integrity: sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==}
|
||||
engines: {node: ^12.20 || ^14.13.1 || >= 16}
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user