Menambahkan beberapa perubahan
This commit is contained in:
@@ -783,6 +783,20 @@
|
||||
document.getElementById('error-msg').classList.remove('show');
|
||||
}
|
||||
|
||||
async function cekKesehatanServer() {
|
||||
try {
|
||||
const res = await fetch('api_auth.php', { method: 'GET' });
|
||||
const text = await res.text();
|
||||
if (text.trim().startsWith('<?php')) {
|
||||
tampilError('PHP tidak berjalan di server deploy. File .php ditampilkan mentah — gunakan hosting dengan PHP (Apache/Nginx+PHP-FPM), bukan static site saja.');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleLogin(e) {
|
||||
e.preventDefault();
|
||||
sembunyiError();
|
||||
@@ -808,7 +822,25 @@
|
||||
body: JSON.stringify({ username, password, role: roleSelected })
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
const raw = await res.text();
|
||||
if (raw.trim().startsWith('<?php')) {
|
||||
tampilError('PHP tidak berjalan di server. Deploy ulang dengan runtime PHP + MySQL (lihat Dockerfile di repo).');
|
||||
btn.classList.remove('loading');
|
||||
btnText.textContent = 'Masuk';
|
||||
btnArrow.textContent = '→';
|
||||
return;
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(raw);
|
||||
} catch {
|
||||
tampilError('Respons server tidak valid. Periksa /health.php — kemungkinan PHP atau MySQL belum aktif.');
|
||||
btn.classList.remove('loading');
|
||||
btnText.textContent = 'Masuk';
|
||||
btnArrow.textContent = '→';
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.success) {
|
||||
sessionStorage.setItem('webgis_user', JSON.stringify({
|
||||
@@ -829,13 +861,15 @@
|
||||
btnArrow.textContent = '→';
|
||||
}
|
||||
} catch {
|
||||
tampilError('Gagal terhubung ke server. Pastikan Apache & MySQL aktif.');
|
||||
tampilError('Gagal terhubung ke server. PHP/MySQL mungkin belum aktif — buka /health.php untuk diagnosa.');
|
||||
btn.classList.remove('loading');
|
||||
btnText.textContent = 'Masuk';
|
||||
btnArrow.textContent = '→';
|
||||
}
|
||||
}
|
||||
|
||||
cekKesehatanServer();
|
||||
|
||||
// Handle logout redirect
|
||||
if (new URLSearchParams(location.search).get('logout')) {
|
||||
sessionStorage.removeItem('webgis_user');
|
||||
|
||||
Reference in New Issue
Block a user