mirror of
https://github.com/xfarrow/blink
synced 2025-04-16 17:07:48 +02:00
91 lines
2.6 KiB
HTML
91 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Sign Up to Blink</title>
|
|
<link rel="stylesheet" href="../css/login-register.css">
|
|
</head>
|
|
|
|
<body>
|
|
<div id="login-form-wrap">
|
|
<h2>Sign Up</h2>
|
|
<form id="login-form">
|
|
|
|
<p>
|
|
<input type="text" id="displayname" name="displayname" placeholder="Your name" required><i
|
|
class="validation"><span></span><span></span></i>
|
|
</p>
|
|
|
|
<p>
|
|
<input type="email" id="email" name="email" placeholder="Email Address" required><i
|
|
class="validation"><span></span><span></span></i>
|
|
</p>
|
|
|
|
<p>
|
|
<input type="password" id="password" name="password" placeholder="Password" required><i
|
|
class="validation"><span></span><span></span></i>
|
|
</p>
|
|
|
|
<p>
|
|
<button type="button" onclick="register(); return false;">Register</button>
|
|
</p>
|
|
</form>
|
|
<div id="create-account-wrap">
|
|
<p>Already a member? <a href="./login.html">Login</a>
|
|
<p>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="../js/constants.js"></script>
|
|
<script src="../js/utils.js"></script>
|
|
|
|
<script>
|
|
async function register() {
|
|
const display_name = document.getElementById('displayname').value;
|
|
const email = document.getElementById('email').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
if (!display_name || !email || !password) {
|
|
alert('Please fill in all fields');
|
|
return;
|
|
}
|
|
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
display_name,
|
|
email,
|
|
password
|
|
}),
|
|
};
|
|
|
|
fetch(`${API_URL}/persons`, options)
|
|
.then(response => {
|
|
response.json().then(data => {
|
|
if (response.ok) {
|
|
if (!data.enabled) { // is the user already enabled or do they need email verification?
|
|
alert("Congratulations! You've successfully registered to Blink. " +
|
|
"Please click on the e-mail we sent you to confirm your account");
|
|
} else {
|
|
alert("Congratulations! You've successfully registered to Blink. " +
|
|
"You can now log in");
|
|
}
|
|
window.location.href = '/login.html';
|
|
} else {
|
|
callbackErrors(data.errors, alert);
|
|
}
|
|
});
|
|
})
|
|
.catch(err => {
|
|
alert("An error has occurred :-( please try again later");
|
|
console.error(err);
|
|
});
|
|
return false;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |