From 4912a0dbe7b1df1e884b53544943319f8f0c0ebb Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Thu, 30 Dec 2021 16:34:50 +0100
Subject: barebones authentication

---
 web/pw-server/src/routes/register.svelte | 38 ++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 web/pw-server/src/routes/register.svelte

(limited to 'web/pw-server/src/routes/register.svelte')

diff --git a/web/pw-server/src/routes/register.svelte b/web/pw-server/src/routes/register.svelte
new file mode 100644
index 0000000..a21cf65
--- /dev/null
+++ b/web/pw-server/src/routes/register.svelte
@@ -0,0 +1,38 @@
+<script lang="ts">
+	let username: string | undefined;
+	let password: string | undefined;
+
+	const onSubmit = () => {
+		if (username === undefined || username.trim() === '') {
+			return;
+		}
+
+    if (password === undefined || password.trim() === '') {
+      return;
+    }
+
+		fetch('/api/register', {
+			method: 'POST',
+			headers: {
+				'Content-Type': 'application/json'
+			},
+			body: JSON.stringify({
+				username,
+				password
+			})
+		})
+			.then((resp) => resp.json())
+			.then((data) => {
+				console.log(data);
+			});
+	};
+</script>
+
+<h1>Register</h1>
+<form on:submit|preventDefault={onSubmit}>
+	<label for="username">Username</label>
+	<input name="username" bind:value={username} />
+	<label for="password">Password</label>
+	<input type="password" name="password" bind:value={password} />
+	<button type="submit">Register</button>
+</form>
-- 
cgit v1.2.3

