Added logging for creating and deleting sessions

This commit is contained in:
Lukasdotcom
2022-01-21 17:22:27 -05:00
parent 24583af52f
commit 9d8f052140
2 changed files with 12 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ if (array_key_exists("get", $_GET)) {
$key = $_POST["delete"];
dbCommand("DELETE FROM cookies WHERE username='$USERNAME' and cookie='$key'");
echo "Deleted session";
writeLog(21, "User $USERNAME revoked session with ip $address");
} else if (array_key_exists("create", $_POST)) {
$expire = intval($_POST["create"]);
$cookie = $USERNAME;
@@ -14,6 +15,7 @@ if (array_key_exists("get", $_GET)) {
$cookie = sanitize(substr(sha1($cookie), 5));
dbCommand("INSERT INTO cookies VALUES ('$cookie', '$USERNAME', $expire, '$address')");
echo "Created new session";
writeLog(22, "User $USERNAME created session with ip $address");
} else {
http_response_code(400);
echo "Invalid command";

View File

@@ -103,5 +103,15 @@
"type": "20",
"name": "Backup deleted",
"color": "#009966"
},
{
"type": "21",
"name": "Session revoked",
"color": "#00ccff"
},
{
"type": "22",
"name": "Session created",
"color": "#00ccff"
}
]