This commit is contained in:
xfarrow 2024-03-14 15:29:27 +01:00
parent d13a6b45e6
commit b2abaf7685
3 changed files with 19 additions and 13 deletions

View File

@ -24,4 +24,4 @@ POSTGRES_PORT = 5432
# Application settings # Application settings
ALLOW_USER_REGISTRATION = true ALLOW_USER_REGISTRATION = true
NEEDS_EMAIL_VERIFICATION = true # Does this server need users to verify their e-mail address? NEEDS_EMAIL_VERIFICATION = false # Does this server need users to verify their e-mail address?

View File

@ -9,7 +9,6 @@
</head> </head>
<body> <body>
<!-- partial:index.partial.html -->
<div id="login-form-wrap"> <div id="login-form-wrap">
<h2>Sign Up</h2> <h2>Sign Up</h2>
<form id="login-form"> <form id="login-form">
@ -30,7 +29,7 @@
</p> </p>
<p> <p>
<button type="button" onclick="register()">Register</button> <button type="button" onclick="register(); return false;">Register</button>
</p> </p>
</form> </form>
<div id="create-account-wrap"> <div id="create-account-wrap">
@ -43,7 +42,7 @@
<script src="../js/utils.js"></script> <script src="../js/utils.js"></script>
<script> <script>
function register() { async function register() {
const display_name = document.getElementById('displayname').value; const display_name = document.getElementById('displayname').value;
const email = document.getElementById('email').value; const email = document.getElementById('email').value;
const password = document.getElementById('password').value; const password = document.getElementById('password').value;
@ -67,20 +66,27 @@
fetch(`${API_URL}/persons`, options) fetch(`${API_URL}/persons`, options)
.then(response => { .then(response => {
if (response.ok) { response.json().then(data => {
alert("Congratulations! You've successfully registered to Blink." + if (response.ok) {
" Please click on the e-mail we sent you to confirm your account"); if (!data.enabled) { // is the user already enabled or do they need email verification?
alert("Congratulations! You've successfully registered to Blink. " +
window.location.href = '/login.html'; "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 {
alert(data.error);
}
});
}) })
.catch(err => { .catch(err => {
alert("An error has occurred :-( please try again later") alert("An error has occurred :-( please try again later");
console.error(err); console.error(err);
}); });
return false;
} }
</script> </script>
</body> </body>
</html> </html>