Initial release MARS_NWE-PCAP 0.4 - Native Administration, Print and Login Edition
This commit is contained in:
3
websetup/login.js
Normal file
3
websetup/login.js
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
const form=document.getElementById('login'), error=document.getElementById('loginError');
|
||||
form.addEventListener('submit',async e=>{e.preventDefault();const button=form.querySelector('button');button.disabled=true;error.textContent='';try{const r=await fetch('/api/login',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({user:document.getElementById('user').value,password:document.getElementById('password').value}),credentials:'same-origin'});const d=await r.json();if(!r.ok)throw Error(d.error||'Anmeldung fehlgeschlagen');location.replace('/');}catch(e){error.textContent=e.message;document.getElementById('password').value='';}finally{button.disabled=false;}});
|
||||
Reference in New Issue
Block a user