Finish login
This commit is contained in:
12
main.php
12
main.php
@@ -29,7 +29,6 @@ class mcServ {
|
||||
|
||||
public function checkLogin() {
|
||||
if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["device_id"])) {
|
||||
echo "Keine Cookies gesetzt";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,20 +37,27 @@ class mcServ {
|
||||
$json = json_decode(file_get_contents($config["PATH"] . "/tmp/user_sessions/" . $_COOKIE["username"] . ".json"), true);
|
||||
|
||||
if (!isset($json[$_COOKIE["device_id"]])) {
|
||||
echo "Device ID gibt es nicht im JSON";
|
||||
return false;
|
||||
}
|
||||
|
||||
$device = json_decode($json[$_COOKIE["device_id"]], true);
|
||||
|
||||
if ($device["session_id"] !== $_COOKIE["session_id"]) {
|
||||
echo "Session IDs stimmen nicht überein";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDB() {
|
||||
$config = $this->getConf();
|
||||
|
||||
$db = new PDO("sqlite:" . $config["DB_PATH"]);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
return $db;
|
||||
}
|
||||
|
||||
public function generateSessionID() {
|
||||
$num = rand(1, 999999);
|
||||
$hash = hash("sha256", $num);
|
||||
|
||||
Reference in New Issue
Block a user