fix
This commit is contained in:
23
internal/server/templates/static/login.js
Normal file
23
internal/server/templates/static/login.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// Login form handler
|
||||
document.getElementById('login-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
try {
|
||||
const res = await fetch('/admin/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, password })
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.message || 'Login failed');
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Connection error');
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user