a cloud service to enable your own web server (owned by you and running on your computer) to be accessible on the internet in seconds, no credit card required
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
2.1 KiB

<div class="horizontal space-around">
<form action="/register" method="POST" class="box vertical">
<h3>register</h3>
<input type="text" name="email" placeholder="email address" value="{{ .Email }}"></input>
<input type="password" name="password" placeholder="password"></input>
<input type="password" name="password2" placeholder="re-enter password"></input>
<input type="hidden" name="hashedPassword"/>
<input type="hidden" name="passwordSalt" value="{{ .PasswordHashSalt }}"/>
<noscript>
<input type="submit" value="Register"></input>
</noscript>
<div class="js-form-submit-button">Register</div>
</form>
<script>
(function(greenhouse, undefined) {
const KEYCODE_ENTER = 13;
const form = document.querySelector('form[action="/register"]');
const submitButton = form.querySelector(".js-form-submit-button");
submitButton.style.display = 'block';
const submitForm = () => {
const passwordElement1 = form.querySelector("input[name=password]");
const passwordElement2 = form.querySelector("input[name=password2]");
if(passwordElement1.value != passwordElement2.value) {
greenhouse.flash("error", "the two password fields don't match!");
} else if(passwordElement1.value.length < 6) {
greenhouse.flash("error", "password must be at least 6 characters long");
} else {
greenhouse.clearFlash();
const salt = form.querySelector("input[name=passwordSalt]").value;
const hashBits = greenhouse.sjcl.hash.sha256.hash(`${salt}${passwordElement1.value}`);
form.querySelector("input[name=hashedPassword]").value = greenhouse.sjcl.codec.base64.fromBits(hashBits);
passwordElement1.value = "***************";
passwordElement2.value = "***************";
form.submit();
}
};
window.addEventListener("keydown", (event) => {
if(event.keyCode == KEYCODE_ENTER) {
submitForm();
}
})
submitButton.onclick = submitForm;
})(window.greenhouse);
</script>
</div>