Feat. Auth is taken directly from the URL, auth on form removed

#3
This commit is contained in:
eoghan.conlon 2023-08-05 16:39:02 +01:00
parent 4a1fb8481b
commit 20e284fb13

View file

@ -8,8 +8,6 @@
<body> <body>
<h1>Sign-up</h1> <h1>Sign-up</h1>
<form id="register"> <form id="register">
<label for="auth">Auth code</label>
<input type="text" id="auth" name="auth" /> <br/>
<label for="user">Username</label> <label for="user">Username</label>
<input type="text" id="user" name="user" /> <br /> <input type="text" id="user" name="user" /> <br />
<label for="pass">Password</label> <label for="pass">Password</label>
@ -27,10 +25,12 @@
function formHandler(listener){ function formHandler(listener){
listener.preventDefault(); listener.preventDefault();
const formData = new FormData(formEl); const formData = new FormData(formEl);
const auth = formData.get("auth"); const url = new URL(window.location.href);
const urlParam = new URLSearchParams(url.search);
const auth = urlParam.get("auth");
const user = formData.get("user"); const user = formData.get("user");
const pass = formData.get("pass"); const pass = formData.get("pass");
const object = { auth: auth, user: user, pass: pass } const object = { auth: auth, user: user, pass: pass };
fetch('https://api.sso.skynet.ie/ldap/new', { fetch('https://api.sso.skynet.ie/ldap/new', {
method: 'POST', method: 'POST',
body: JSON.stringify(object), body: JSON.stringify(object),
@ -53,7 +53,7 @@
} }
} }
}) })
.catch(() => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>") .catch(() => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>");
} }
</script> </script>
</body> </body>