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