mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Add csrf token check, destroy session on timeout
This commit is contained in:
parent
50ed5f9f4b
commit
ec0dd304ee
5
ajax/session/do_check_session.php
Normal file → Executable file
5
ajax/session/do_check_session.php
Normal file → Executable file
@ -10,6 +10,11 @@ $lastActivity = $_SESSION['lastActivity'] ?? time();
|
|||||||
$sessionLifetime = time() - $lastActivity;
|
$sessionLifetime = time() - $lastActivity;
|
||||||
$status = $sessionLifetime >= RASPI_SESSION_TIMEOUT ? 'session_expired' : 'active';
|
$status = $sessionLifetime >= RASPI_SESSION_TIMEOUT ? 'session_expired' : 'active';
|
||||||
|
|
||||||
|
if ($status = 'session_expired') {
|
||||||
|
session_unset(); // unset all session variables
|
||||||
|
session_destroy(); // destroy the session
|
||||||
|
}
|
||||||
|
|
||||||
// send response
|
// send response
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
||||||
|
@ -678,7 +678,8 @@ function checkSession() {
|
|||||||
if (window.location.pathname === '/login') {
|
if (window.location.pathname === '/login') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.get('ajax/session/do_check_session.php', function (data) {
|
var csrfToken = $('meta[name=csrf_token]').attr('content');
|
||||||
|
$.post('ajax/session/do_check_session.php',{'csrf_token': csrfToken},function (data) {
|
||||||
if (data.status === 'session_expired') {
|
if (data.status === 'session_expired') {
|
||||||
clearInterval(sessionCheckInterval);
|
clearInterval(sessionCheckInterval);
|
||||||
showSessionExpiredModal();
|
showSessionExpiredModal();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user