Fix env loading and auth response verification

This commit is contained in:
ilham_gmail
2026-06-11 19:27:44 +07:00
parent 51411d7e76
commit ff5ff49597
3 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -582,8 +582,8 @@ function openAuthModal(mode){
resp = await fetch(endpoint, { method: 'POST', headers: buildHeaders(), body: JSON.stringify(payload), credentials: 'same-origin' }); resp = await fetch(endpoint, { method: 'POST', headers: buildHeaders(), body: JSON.stringify(payload), credentials: 'same-origin' });
jr = await resp.json().catch(()=>null); jr = await resp.json().catch(()=>null);
} }
if(!resp.ok || (jr && jr.success === false)){ if(!resp.ok || !jr || jr.success === false){
showToast((jr && (jr.error || jr.status)) ? (jr.error || jr.status) : 'Gagal', 'error', 5000); showToast((jr && (jr.error || jr.status)) ? (jr.error || jr.status) : 'Gagal memproses respons dari server', 'error', 5000);
return; return;
} }
if(mode === 'register'){ if(mode === 'register'){
+4 -2
View File
@@ -12,8 +12,10 @@ function load_dotenv($path){
if((substr($v,0,1)==='"' && substr($v,-1)==='"') || (substr($v,0,1)==="'" && substr($v,-1)==="'")){ if((substr($v,0,1)==='"' && substr($v,-1)==='"') || (substr($v,0,1)==="'" && substr($v,-1)==="'")){
$v = substr($v,1,-1); $v = substr($v,1,-1);
} }
putenv("$k=$v"); if(getenv($k) === false){
$_ENV[$k] = $v; putenv("$k=$v");
$_ENV[$k] = $v;
}
} }
} }
+4 -2
View File
@@ -12,8 +12,10 @@ function load_dotenv($path){
if((substr($v,0,1)==='"' && substr($v,-1)==='"') || (substr($v,0,1)==="'" && substr($v,-1)==="'")){ if((substr($v,0,1)==='"' && substr($v,-1)==='"') || (substr($v,0,1)==="'" && substr($v,-1)==="'")){
$v = substr($v,1,-1); $v = substr($v,1,-1);
} }
putenv("$k=$v"); if(getenv($k) === false){
$_ENV[$k] = $v; putenv("$k=$v");
$_ENV[$k] = $v;
}
} }
} }