From ff5ff49597bc10f7bc52cf4da29d7bff00549a2a Mon Sep 17 00:00:00 2001 From: ilham_gmail Date: Thu, 11 Jun 2026 19:27:44 +0700 Subject: [PATCH] Fix env loading and auth response verification --- poverty-mapping/index.html | 4 ++-- poverty-mapping/src/config/config.php | 6 ++++-- tugas-spbu/src/config/config.php | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/poverty-mapping/index.html b/poverty-mapping/index.html index 97d3aba..39c3b48 100644 --- a/poverty-mapping/index.html +++ b/poverty-mapping/index.html @@ -582,8 +582,8 @@ function openAuthModal(mode){ resp = await fetch(endpoint, { method: 'POST', headers: buildHeaders(), body: JSON.stringify(payload), credentials: 'same-origin' }); jr = await resp.json().catch(()=>null); } - if(!resp.ok || (jr && jr.success === false)){ - showToast((jr && (jr.error || jr.status)) ? (jr.error || jr.status) : 'Gagal', 'error', 5000); + if(!resp.ok || !jr || jr.success === false){ + showToast((jr && (jr.error || jr.status)) ? (jr.error || jr.status) : 'Gagal memproses respons dari server', 'error', 5000); return; } if(mode === 'register'){ diff --git a/poverty-mapping/src/config/config.php b/poverty-mapping/src/config/config.php index b5b21f1..70ceb30 100644 --- a/poverty-mapping/src/config/config.php +++ b/poverty-mapping/src/config/config.php @@ -12,8 +12,10 @@ function load_dotenv($path){ if((substr($v,0,1)==='"' && substr($v,-1)==='"') || (substr($v,0,1)==="'" && substr($v,-1)==="'")){ $v = substr($v,1,-1); } - putenv("$k=$v"); - $_ENV[$k] = $v; + if(getenv($k) === false){ + putenv("$k=$v"); + $_ENV[$k] = $v; + } } } diff --git a/tugas-spbu/src/config/config.php b/tugas-spbu/src/config/config.php index 998cefc..5353a3f 100644 --- a/tugas-spbu/src/config/config.php +++ b/tugas-spbu/src/config/config.php @@ -12,8 +12,10 @@ function load_dotenv($path){ if((substr($v,0,1)==='"' && substr($v,-1)==='"') || (substr($v,0,1)==="'" && substr($v,-1)==="'")){ $v = substr($v,1,-1); } - putenv("$k=$v"); - $_ENV[$k] = $v; + if(getenv($k) === false){ + putenv("$k=$v"); + $_ENV[$k] = $v; + } } }