add unenroll to api home page, minor changes

This commit is contained in:
Ean Milligan
2026-04-23 16:51:06 -04:00
parent 1f4c4723d3
commit 8126e6dc95
3 changed files with 23 additions and 5 deletions

View File

@@ -1,10 +1,10 @@
export default `<div>
<script>
function doLogin(){
fetch('/api/auth',{method:'POST',body:JSON.stringify({ name:document.getElementById('name').value.trim(), pin:document.getElementById('pin').value.trim() })})
fetch('/api/auth',{method:'POST',body:JSON.stringify({name:document.getElementById('name').value.trim(),pin:document.getElementById('pin').value.trim()})})
.catch((e)=>{e.text().then((text)=>{alert(text);});})
.then((r) => {
if(r.status===200){r.json().then((j)=>{localStorage.setItem('name', document.getElementById('name').value.trim());window.location.replace('/api/home/'+j.id);});}
if(r.status===200){r.json().then((j)=>{localStorage.setItem('name',document.getElementById('name').value.trim());window.location.replace('/api/home/'+j.id);});}
else{r.text().then((text)=>{alert(text);});}
});
}