diff --git a/package.json b/package.json index d5197ba..614b8ac 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f80c1bc..82c7923 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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} diff --git a/src/routes/pubnix/register/+page.server.ts b/src/routes/pubnix/register/+page.server.ts index 496c982..09ee606 100644 --- a/src/routes/pubnix/register/+page.server.ts +++ b/src/routes/pubnix/register/+page.server.ts @@ -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()); diff --git a/src/routes/pubnix/register/+page.svelte b/src/routes/pubnix/register/+page.svelte index 2a42ff5..1a76892 100644 --- a/src/routes/pubnix/register/+page.svelte +++ b/src/routes/pubnix/register/+page.svelte @@ -1,7 +1,11 @@

{data.title}

@@ -43,6 +47,13 @@ rows="5" required /> +
+ +
+ + {#if form?.success} @@ -53,6 +64,10 @@ {form.message} {/if} +
+

I agree to the Terms of Service

. +
+