Add Database structure

This commit is contained in:
root committed 2026-10-05 10:52:31 +02:00
1 parent f5f42b73ee
commit 3ad5f5bdd6
4 files changed
+19 -4

No files matched your search

Regular → Executable
View File
File mode changed.
Regular → Executable
+2 -2
View File
@@ -28,14 +28,14 @@ $hash = hash("sha256", $password);
$command = "SELECT username, password FROM users WHERE username = :username AND password = :password"; $command = "SELECT username, password FROM users WHERE username = :username AND password = :password";
$args = [ $args = [
":username" => $username, ":username" => $username,
":password" => $password ":password" => $hash
]; ];
// Execute SQL Command // Execute SQL Command
$result = $api->dbCommand($command, true, true, $args); $result = $api->dbCommand($command, true, true, $args);
// Check Result // Check Result
if ($result) { if ($result && password_verify($password, $result["password"])) {
// Login successful. Generate Auth Token // Login successful. Generate Auth Token
$token = $api->generateToken($username); $token = $api->generateToken($username);
+2 -2
View File
@@ -2,7 +2,7 @@
// Load Main Libary // Load Main Libary
require "../api.php"; require "../api.php";
$api = new gbAPI(true); $api = new gbAPI(false);
// Check Request body // Check Request body
if ($_SERVER["REQUEST_METHOD"] !== "POST") { if ($_SERVER["REQUEST_METHOD"] !== "POST") {
@@ -32,7 +32,7 @@ if ($password !== $password_repeat) {
} }
// Hash Password // Hash Password
$hash = hash("sha256", $password); $hash = password_hash($password);
+15
View File
@@ -0,0 +1,15 @@
CREATE TABLE IF NOT EXISTS "users" (
"id" INTEGER NOT NULL,
"username" VARCHAR NOT NULL,
"password" VARCHAR NOT NULL,
"owner" INTEGER NOT NULL,
PRIMARY KEY("id", "username", "owner")
);
CREATE TABLE IF NOT EXISTS "entrys" (
"id" INTEGER NOT NULL,
"name" VARCHAR NOT NULL,
"text" VARCHAR NOT NULL,
"status" INTEGER,
PRIMARY KEY("id")
);