summary refs log tree commit diff
path: root/slowcord/login/public/register.html
diff options
context:
space:
mode:
Diffstat (limited to 'slowcord/login/public/register.html')
-rw-r--r--slowcord/login/public/register.html87
1 files changed, 87 insertions, 0 deletions
diff --git a/slowcord/login/public/register.html b/slowcord/login/public/register.html
new file mode 100644
index 00000000..5843649c
--- /dev/null
+++ b/slowcord/login/public/register.html
@@ -0,0 +1,87 @@
+<html lang="en">
+
+<head>
+	<meta charset="UTF-8">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge">
+	<meta name="viewport" content="width=device-width, initial-scale=1.0">
+	<title>Slowcord</title>
+
+	<link rel="preconnect" href="https://fonts.googleapis.com">
+	<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+	<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
+
+	<link rel="stylesheet" href="./css/index.css">
+</head>
+
+<body>
+	<div class="content">
+		<div class="login">
+			<div class="header">
+				<h1>Welcome to Slowcord</h1>
+				<div class="header-subtext">
+					<p>You're new?</p>
+					<a href="/login">Actually, I'm not!</a>
+				</div>
+
+				<p id="failure">Register failed</p>
+			</div>
+
+
+			<form action="javascript:void(0);">
+				<label for="email">Email</label>
+				<input type="email" name="email" />
+
+				<label for="username">Username</label>
+				<input type="username" name="username" />
+
+				<label for="password">Password</label>
+				<input type="password" name="password" />
+
+				<label for="dob">Date of Birth</label>
+				<input type="date" name="dob" />
+
+				<input type="submit" value="Register" />
+
+				<a id="loginDiscord" class="oauth"
+					href="https://discord.com/api/oauth2/authorize?client_id=991688571415175198&redirect_uri=https%3A%2F%2Fslowcord.maddy.k.vu%2Foauth%2Fdiscord&response_type=code&scope=identify%20email">
+					Login with Discord
+				</a>
+			</form>
+		</div>
+	</div>
+
+	<script>
+		document.forms[0].addEventListener("submit", async (e) => {
+			const data = new FormData(e.target);
+			const email = data.get("email");
+			const username = data.get("username");
+			const password = data.get("password");
+			const dob = data.get("dob");
+
+			const response = await fetch("/api/v9/auth/register", {
+				method: "POST",
+				headers: {
+					"Content-Type": "application/json",
+				},
+				body: JSON.stringify({
+					consent: true,
+					email: email,
+					username: username,
+					password: password,
+					date_of_birth: dob,
+				})
+			});
+
+			const json = await response.json();
+			if (json.token) {
+				window.localStorage.setItem("token", `"${json.token}"`);
+				window.location.href = "/app";
+				return;
+			}
+
+			document.getElementById("failure").style.display = "block";
+		})
+	</script>
+</body>
+
+</html>
\ No newline at end of file