From 0eded6402c9f3bae461b464f99ef1d37e46171eb Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:17:13 +0330 Subject: [PATCH] Import source: vault/app/register/page Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- vault/app/register/page.tsx | 131 ++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 vault/app/register/page.tsx diff --git a/vault/app/register/page.tsx b/vault/app/register/page.tsx new file mode 100644 index 0000000..406190d --- /dev/null +++ b/vault/app/register/page.tsx @@ -0,0 +1,131 @@ +"use client"; + +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; +import { RefreshCw, UserPlus } from "lucide-react"; +import { toast } from "sonner"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { api } from "@/lib/api-client"; + +export default function RegisterPage() { + const router = useRouter(); + const [name, setName] = useState(""); + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + const [captcha, setCaptcha] = useState(""); + const [challenge, setChallenge] = useState(""); + const [submitting, setSubmitting] = useState(false); + + const loadCaptcha = async () => { + const { challenge } = await api.captcha(); + setChallenge(challenge); + setCaptcha(""); + }; + + useEffect(() => { + api.captcha() + .then(({ challenge }) => setChallenge(challenge)) + .catch(() => toast.error("Unable to load captcha")); + }, []); + + const handleSubmit = async (event: React.FormEvent) => { + event.preventDefault(); + setSubmitting(true); + + try { + await api.register(name, username, password, captcha); + toast.success("Account created"); + router.push("/snippets"); + router.refresh(); + } catch (error) { + toast.error(error instanceof Error ? error.message : "Unable to create account"); + await loadCaptcha(); + } finally { + setSubmitting(false); + } + }; + + return ( +
+
+
+
+ +
+
+

Create account

+

Create a fully local account for CVault.

+
+
+ +
+
+ + setName(event.target.value)} + className="h-11 bg-muted/50 border-border/50" + required + /> +
+ +
+ + setUsername(event.target.value)} + className="h-11 bg-muted/50 border-border/50" + required + /> +
+ +
+ + setPassword(event.target.value)} + className="h-11 bg-muted/50 border-border/50" + minLength={8} + required + /> +
+ +
+
+ + +
+ setCaptcha(event.target.value)} + className="h-11 bg-muted/50 border-border/50" + required + /> +
+ + +
+ +

+ Already have an account?{" "} + + Sign in + +

+
+
+ ); +}