fix login loop

This commit is contained in:
Focuslinkstech 2024-10-10 16:24:36 +01:00 committed by GitHub
parent 82ffc15c03
commit 60e1eacc59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,11 +47,11 @@ class Admin
if (sha1("$tmp[0].$tmp[1].$db_pass") == $tmp[2]) { if (sha1("$tmp[0].$tmp[1].$db_pass") == $tmp[2]) {
// Validate the token in the cookie // Validate the token in the cookie
$isValid = self::validateToken($tmp[0], $_COOKIE['aid']); $isValid = self::validateToken($tmp[0], $_COOKIE['aid']);
if (!$isValid) { if (!empty($_COOKIE['aid']) && !$isValid) {
self::removeCookie(); self::removeCookie();
_alert(Lang::T('Token has expired. Please log in again.'), 'danger', "admin"); _alert(Lang::T('Token has expired. Please log in again.'), 'danger', "admin");
return 0; return 0;
} } else {
if (time() - $tmp[1] < 86400 * 7) { if (time() - $tmp[1] < 86400 * 7) {
$_SESSION['aid'] = $tmp[0]; $_SESSION['aid'] = $tmp[0];
@ -62,6 +62,7 @@ class Admin
} }
} }
} }
}
return 0; return 0;
} }
@ -83,7 +84,7 @@ class Admin
setcookie('aid', $token, [ setcookie('aid', $token, [
'expires' => time() + 86400 * 7, // 7 days 'expires' => time() + 86400 * 7, // 7 days
'path' => '/', 'path' => '/',
'domain' => $app_stage, 'domain' => '',
'secure' => $isSecure, 'secure' => $isSecure,
'httponly' => true, 'httponly' => true,
'samesite' => 'Lax', // or Strict 'samesite' => 'Lax', // or Strict
@ -113,7 +114,7 @@ class Admin
setcookie('aid', '', [ setcookie('aid', '', [
'expires' => time() - 3600, 'expires' => time() - 3600,
'path' => '/', 'path' => '/',
'domain' => $app_stage, 'domain' => '',
'secure' => $isSecure, 'secure' => $isSecure,
'httponly' => true, 'httponly' => true,
'samesite' => 'Lax', 'samesite' => 'Lax',