From 7281197838986467880d88d265de5c003efc8b6b Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 15 Jan 2021 10:03:33 +0100 Subject: register werks --- src/components/navbar.tsx | 2 +- src/components/ui.tsx | 5 ++-- src/pages/login.tsx | 2 +- src/pages/register.tsx | 76 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 76 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index e5d2915..7725ca8 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -49,7 +49,7 @@ export function NavBar() {
diff --git a/src/components/ui.tsx b/src/components/ui.tsx index 29f77ff..c2ce35e 100644 --- a/src/components/ui.tsx +++ b/src/components/ui.tsx @@ -57,9 +57,10 @@ export function Button(props: { export function Input(props: { label?: string, style?: CSSProperties, - type?: string + type?: string, + id?: string }) { - return react toast / material-ui snackbar + if ( formData.username.length > 35 ) { + alert("Je gebruikersnaam kan maximaal 35 tekens lang zijn!"); + } + + if ( !validateEmail(formData.email) ) { + alert("Voer alsjeblieft een geldig e-mail adres in!"); + } + + //TODO: wachtwoord max 72 tekens ivm bcrypt + if ( !formData.password.match(passwordRegex) ) { + alert("Je wachtwoord moet minimaal 8 tekens lang zijn en een hoofdletter, kleine letter, en een nummer bevatten!"); + } + + axios({ + method: "post", + url: `${window.location.origin}/api/auth/signup`, + headers: {"content-type": "application/json"}, + data: formData + }) + .then(() => { + //TODO: email verificatie + // redirect naar home, automatische login + window.location.pathname = "/"; + }) + .catch(error => { + alert("Er is iets fout gegaan!"); + console.log(error); + }); +} + export default function RegisterPage() { return (
@@ -15,10 +81,10 @@ export default function RegisterPage() { textAlign: "center" }}> - - - - + + + +
-- cgit v1.2.3