Fixes CSRF issue after login with 2fa code
parent
2ca1714992
commit
d28d69d350
|
@ -12,10 +12,18 @@ function applyCsrfMiddleware() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip CSRF check for initial login, registration, and 2FA verification attempts
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' &&
|
||||||
|
isset($_GET['page']) && isset($_GET['action']) &&
|
||||||
|
$_GET['page'] === 'login' && $_GET['action'] === 'verify' &&
|
||||||
|
isset($_SESSION['2fa_pending_user_id'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip CSRF check for initial login and registration attempts
|
// Skip CSRF check for initial login and registration attempts
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' &&
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' &&
|
||||||
isset($_GET['page']) &&
|
isset($_GET['page']) &&
|
||||||
in_array($_GET['page'], ['login', 'register']) &&
|
in_array($_GET['page'], ['login', 'register']) &&
|
||||||
!isset($_SESSION['username'])) {
|
!isset($_SESSION['username'])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue