blink/frontend/vanilla/html/register.html

76 lines
2.4 KiB
HTML
Raw Normal View History

2023-10-18 13:03:41 +02:00
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
2023-10-18 15:02:34 +02:00
<title>Sign Up to Blink</title>
2023-10-18 13:03:41 +02:00
<link rel="stylesheet" href="../css/login-register.css">
<script src=""></script>
</head>
<body>
<!-- partial:index.partial.html -->
<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()">Register</button>
</p>
</form>
<div id="create-account-wrap">
<p>Already a member? <a href="./login.html">Login</a><p>
</div>
</div>
2024-03-04 09:09:11 +01:00
<script src="../js/constants.js"></script>
<script src="../js/utils.js"></script>
2023-10-18 13:03:41 +02:00
<script>
2023-10-18 15:02:34 +02:00
2023-10-18 13:03:41 +02:00
function register(){
2024-03-04 09:09:11 +01:00
const display_name = document.getElementById('displayname').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
2023-10-18 13:03:41 +02:00
if(!display_name || !email || !password){
2024-03-04 09:09:11 +01:00
alert('Please fill in all fields');
2023-10-18 13:03:41 +02:00
}
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ display_name, email, password }),
};
2023-10-18 15:17:04 +02:00
2024-03-04 09:09:11 +01:00
fetch(`${API_URL}/register`, options)
2023-10-18 13:03:41 +02:00
.then(response => {
if (response.ok) {
2023-10-18 15:17:04 +02:00
alert("Congratulations! You've successfully registered to Blink." +
" Please click on the e-mail we sent you to confirm your account");
2023-10-18 15:36:43 +02:00
window.location.href = '/login.html';
2023-10-18 13:03:41 +02:00
}
})
.catch(err => {
2023-10-18 15:36:43 +02:00
alert("An error has occurred :-( please try again later")
2023-10-18 13:03:41 +02:00
console.error(err);
});
}
</script>
</body>
</html>