20 lines
738 B
TypeScript
20 lines
738 B
TypeScript
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() })
|
|
}).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);});}
|
|
else{r.text().then((text)=>{alert(text);});}
|
|
});
|
|
}
|
|
</script>
|
|
<p>Please sign in:</p>
|
|
<label>Name: <input id="name" type="text" autocomplete="off"/></label>
|
|
<br/>
|
|
<label>PIN: <input id="pin" type="password" autocomplete="off"/></label>
|
|
<br/>
|
|
<button onclick="doLogin()">Sign In</button>
|
|
</div>`;
|