From c23a10eb6e8ac17a090b9b3587469ce6b4183a7c Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 22:34:12 +0200 Subject: [PATCH 01/12] Implement database-based user management --- php/controller/register-controller.php | 4 +- php/model/DatabaseUserManager.php | 243 ++++++++++++++++++++++++- php/model/UserManager.php | 32 +++- 3 files changed, 266 insertions(+), 13 deletions(-) diff --git a/php/controller/register-controller.php b/php/controller/register-controller.php index 5a0de05..db3dce0 100644 --- a/php/controller/register-controller.php +++ b/php/controller/register-controller.php @@ -1,6 +1,6 @@ exec(" + CREATE TABLE users ( + email TEXT PRIMARY KEY, + vorname TEXT, + nachname TEXT, + password TEXT + ); + "); + + unset($db); + + } catch (PDOException $e) { + throw new RuntimeException($e->getMessage()); + } + } + } + /** + * Baut die Verbindung zur Datenbank auf. + */ + private function getConnection() + { + try { + $user = 'root'; + $pw = null; + $dsn = 'sqlite:' . __DIR__ . '/../../db/users.db'; + + return new PDO($dsn, $user, $pw); + + } catch (PDOException $e) { + throw new RuntimeException($e->getMessage()); + } + } + + /** + * Singleton-Instanz zurückgeben. + */ + public static function getInstance() + { + if (self::$instance == null) { + self::$instance = new DatabaseUserManager(); + } + + return self::$instance; + } + + public function findUser($email) { - // TODO: Implement findUser() method. + try { + $db = $this->getConnection(); + + $sql = "SELECT * FROM users WHERE email = :email"; + + $command = $db->prepare($sql); + + if (!$command) { + throw new RuntimeException("Benutzer konnte nicht geladen werden."); + } + + $command->execute([ + ":email" => $email + ]); + + $user = $command->fetch(PDO::FETCH_ASSOC); + + return $user ?: null; + + } catch (PDOException $e) { + throw new RuntimeException($e->getMessage()); + } } public function addUser($email, $vorname, $nachname, $password) { - // TODO: Implement addUser() method. + try { + $db = $this->getConnection(); + + $db->beginTransaction(); + + $existingUser = $this->findUser($email); + + if ($existingUser !== null) { + $db->rollBack(); + throw new InvalidArgumentException( + "Diese E-Mail-Adresse wird bereits verwendet." + ); + } + + $sql = " + INSERT INTO users ( + email, + vorname, + nachname, + password + ) + VALUES ( + :email, + :vorname, + :nachname, + :password + ) + "; + + $command = $db->prepare($sql); + + if (!$command) { + $db->rollBack(); + throw new RuntimeException( + "Benutzer konnte nicht gespeichert werden." + ); + } + + $success = $command->execute([ + ":email" => $email, + ":vorname" => $vorname, + ":nachname" => $nachname, + ":password" => $password + ]); + + if (!$success) { + $db->rollBack(); + throw new RuntimeException( + "Benutzer konnte nicht gespeichert werden." + ); + } + + $db->commit(); + + } catch (PDOException $e) { + throw new RuntimeException($e->getMessage()); + } } - public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) - { - // TODO: Implement updateUser() method. + public function updateUser( + $oldEmail, + $newEmail, + $vorname, + $nachname, + $password = null + ) { + try { + $db = $this->getConnection(); + + if ($oldEmail !== $newEmail) { + + $existingUser = $this->findUser($newEmail); + + if ($existingUser !== null) { + throw new InvalidArgumentException( + "Diese E-Mail-Adresse wird bereits verwendet." + ); + } + } + + if (!empty($password)) { + + $sql = " + UPDATE users + SET + email = :newEmail, + vorname = :vorname, + nachname = :nachname, + password = :password + WHERE email = :oldEmail + "; + + $params = [ + ":newEmail" => $newEmail, + ":vorname" => $vorname, + ":nachname" => $nachname, + ":password" => password_hash( + $password, + PASSWORD_DEFAULT + ), + ":oldEmail" => $oldEmail + ]; + + } else { + + $sql = " + UPDATE users + SET + email = :newEmail, + vorname = :vorname, + nachname = :nachname + WHERE email = :oldEmail + "; + + $params = [ + ":newEmail" => $newEmail, + ":vorname" => $vorname, + ":nachname" => $nachname, + ":oldEmail" => $oldEmail + ]; + } + + $command = $db->prepare($sql); + + if (!$command) { + throw new RuntimeException( + "Benutzer konnte nicht aktualisiert werden." + ); + } + + $command->execute($params); + + return $command->rowCount() > 0; + + } catch (PDOException $e) { + throw new RuntimeException($e->getMessage()); + } } public function deleteUser($email) { - // TODO: Implement deleteUser() method. + try { + $db = $this->getConnection(); + + $sql = "DELETE FROM users WHERE email = :email"; + + $command = $db->prepare($sql); + + if (!$command) { + throw new RuntimeException( + "Benutzer konnte nicht gelöscht werden." + ); + } + + $command->execute([ + ":email" => $email + ]); + + return $command->rowCount() > 0; + + } catch (PDOException $e) { + throw new RuntimeException($e->getMessage()); + } } } \ No newline at end of file diff --git a/php/model/UserManager.php b/php/model/UserManager.php index 1ff7b28..0cca25d 100644 --- a/php/model/UserManager.php +++ b/php/model/UserManager.php @@ -1,10 +1,32 @@ findUser("mustermann@web.de") == null) { + $userManager->addUser( + "mustermann@web.de", + "Max", + "Mustermann", + password_hash("test123", PASSWORD_DEFAULT) + ); + } + + return $userManager; } } \ No newline at end of file -- 2.47.3 From 4abfe801ecfcf576685ef79b54034680bc1d12d2 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 22:54:18 +0200 Subject: [PATCH 02/12] Test --- php/model/DatabaseUserManager.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/php/model/DatabaseUserManager.php b/php/model/DatabaseUserManager.php index 1c08500..efa659b 100644 --- a/php/model/DatabaseUserManager.php +++ b/php/model/DatabaseUserManager.php @@ -7,6 +7,8 @@ class DatabaseUserManager implements UserManagerDAO { private static $instance = null; public function __construct() { + die("DatabaseUserManager wird verwendet"); + if (!file_exists(__DIR__ . '/../../db/users.db')) { try { $user = 'root'; @@ -16,13 +18,13 @@ class DatabaseUserManager implements UserManagerDAO { $db = new PDO($dsn, $user, $pw); $db->exec(" - CREATE TABLE users ( - email TEXT PRIMARY KEY, - vorname TEXT, - nachname TEXT, - password TEXT - ); - "); + CREATE TABLE users ( + email TEXT PRIMARY KEY, + vorname TEXT, + nachname TEXT, + password TEXT + ); + "); unset($db); -- 2.47.3 From 252c14a377184ee20a26bb865ecff28353092164 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 22:56:28 +0200 Subject: [PATCH 03/12] Test --- php/model/DatabaseUserManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/php/model/DatabaseUserManager.php b/php/model/DatabaseUserManager.php index efa659b..bdbd120 100644 --- a/php/model/DatabaseUserManager.php +++ b/php/model/DatabaseUserManager.php @@ -7,7 +7,6 @@ class DatabaseUserManager implements UserManagerDAO { private static $instance = null; public function __construct() { - die("DatabaseUserManager wird verwendet"); if (!file_exists(__DIR__ . '/../../db/users.db')) { try { @@ -17,6 +16,11 @@ class DatabaseUserManager implements UserManagerDAO { $db = new PDO($dsn, $user, $pw); + file_put_contents( + __DIR__ . '/../../db/test.txt', + 'PDO funktioniert' + ); + $db->exec(" CREATE TABLE users ( email TEXT PRIMARY KEY, -- 2.47.3 From 9010b68a3993ac1fdbdc9f7d44e1b4c11a963633 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 23:10:36 +0200 Subject: [PATCH 04/12] Richtig Einbinden --- php/controller/login-controller.php | 3 ++- php/controller/profile-controller.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/php/controller/login-controller.php b/php/controller/login-controller.php index 8e2c2ec..348e301 100644 --- a/php/controller/login-controller.php +++ b/php/controller/login-controller.php @@ -1,6 +1,7 @@ findUser($_SESSION["user_email"] ?? ""); -- 2.47.3 From b9dead1c8b4e7a146640ac42296c8a7b0a29d0f1 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 23:18:35 +0200 Subject: [PATCH 05/12] Fehlerbehebung Passwort speichern --- php/model/DatabaseUserManager.php | 164 ++++++++---------------------- 1 file changed, 41 insertions(+), 123 deletions(-) diff --git a/php/model/DatabaseUserManager.php b/php/model/DatabaseUserManager.php index bdbd120..a985160 100644 --- a/php/model/DatabaseUserManager.php +++ b/php/model/DatabaseUserManager.php @@ -5,58 +5,43 @@ require_once "UserManagerDAO.php"; class DatabaseUserManager implements UserManagerDAO { private static $instance = null; + public function __construct() { + try { + $db = $this->getConnection(); - if (!file_exists(__DIR__ . '/../../db/users.db')) { - try { - $user = 'root'; - $pw = null; - $dsn = 'sqlite:' . __DIR__ . '/../../db/users.db'; - - $db = new PDO($dsn, $user, $pw); - - file_put_contents( - __DIR__ . '/../../db/test.txt', - 'PDO funktioniert' - ); - - $db->exec(" - CREATE TABLE users ( + $db->exec(" + CREATE TABLE IF NOT EXISTS users ( email TEXT PRIMARY KEY, - vorname TEXT, - nachname TEXT, - password TEXT + vorname TEXT NOT NULL, + nachname TEXT NOT NULL, + password TEXT NOT NULL ); "); - unset($db); + unset($db); - } catch (PDOException $e) { - throw new RuntimeException($e->getMessage()); - } + } catch (PDOException $e) { + throw new RuntimeException("Benutzerdatenbank konnte nicht erstellt werden."); } } - /** - * Baut die Verbindung zur Datenbank auf. - */ + private function getConnection() { try { - $user = 'root'; - $pw = null; $dsn = 'sqlite:' . __DIR__ . '/../../db/users.db'; - return new PDO($dsn, $user, $pw); + $db = new PDO($dsn, null, null); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + return $db; } catch (PDOException $e) { - throw new RuntimeException($e->getMessage()); + throw new RuntimeException("Verbindung zur Benutzerdatenbank fehlgeschlagen."); } } - /** - * Singleton-Instanz zurückgeben. - */ public static function getInstance() { if (self::$instance == null) { @@ -66,20 +51,14 @@ class DatabaseUserManager implements UserManagerDAO { return self::$instance; } - public function findUser($email) { try { $db = $this->getConnection(); $sql = "SELECT * FROM users WHERE email = :email"; - $command = $db->prepare($sql); - if (!$command) { - throw new RuntimeException("Benutzer konnte nicht geladen werden."); - } - $command->execute([ ":email" => $email ]); @@ -89,7 +68,7 @@ class DatabaseUserManager implements UserManagerDAO { return $user ?: null; } catch (PDOException $e) { - throw new RuntimeException($e->getMessage()); + throw new RuntimeException("Benutzer konnte nicht geladen werden."); } } @@ -97,90 +76,46 @@ class DatabaseUserManager implements UserManagerDAO { { try { $db = $this->getConnection(); - $db->beginTransaction(); - $existingUser = $this->findUser($email); - - if ($existingUser !== null) { - $db->rollBack(); - throw new InvalidArgumentException( - "Diese E-Mail-Adresse wird bereits verwendet." - ); - } - $sql = " - INSERT INTO users ( - email, - vorname, - nachname, - password - ) - VALUES ( - :email, - :vorname, - :nachname, - :password - ) + INSERT INTO users (email, vorname, nachname, password) + VALUES (:email, :vorname, :nachname, :password) "; $command = $db->prepare($sql); - if (!$command) { - $db->rollBack(); - throw new RuntimeException( - "Benutzer konnte nicht gespeichert werden." - ); - } - - $success = $command->execute([ + $command->execute([ ":email" => $email, ":vorname" => $vorname, ":nachname" => $nachname, ":password" => $password ]); - if (!$success) { - $db->rollBack(); - throw new RuntimeException( - "Benutzer konnte nicht gespeichert werden." - ); - } - $db->commit(); } catch (PDOException $e) { - throw new RuntimeException($e->getMessage()); + if (isset($db) && $db->inTransaction()) { + $db->rollBack(); + } + + if ($e->getCode() === "23000") { + throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet."); + } + + throw new RuntimeException("Benutzer konnte nicht gespeichert werden."); } } - public function updateUser( - $oldEmail, - $newEmail, - $vorname, - $nachname, - $password = null - ) { + public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) + { try { $db = $this->getConnection(); - if ($oldEmail !== $newEmail) { - - $existingUser = $this->findUser($newEmail); - - if ($existingUser !== null) { - throw new InvalidArgumentException( - "Diese E-Mail-Adresse wird bereits verwendet." - ); - } - } - if (!empty($password)) { - $sql = " UPDATE users - SET - email = :newEmail, + SET email = :newEmail, vorname = :vorname, nachname = :nachname, password = :password @@ -191,19 +126,13 @@ class DatabaseUserManager implements UserManagerDAO { ":newEmail" => $newEmail, ":vorname" => $vorname, ":nachname" => $nachname, - ":password" => password_hash( - $password, - PASSWORD_DEFAULT - ), + ":password" => password_hash($password, PASSWORD_DEFAULT), ":oldEmail" => $oldEmail ]; - } else { - $sql = " UPDATE users - SET - email = :newEmail, + SET email = :newEmail, vorname = :vorname, nachname = :nachname WHERE email = :oldEmail @@ -218,19 +147,16 @@ class DatabaseUserManager implements UserManagerDAO { } $command = $db->prepare($sql); - - if (!$command) { - throw new RuntimeException( - "Benutzer konnte nicht aktualisiert werden." - ); - } - $command->execute($params); return $command->rowCount() > 0; } catch (PDOException $e) { - throw new RuntimeException($e->getMessage()); + if ($e->getCode() === "23000") { + throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet."); + } + + throw new RuntimeException("Benutzer konnte nicht aktualisiert werden."); } } @@ -240,15 +166,8 @@ class DatabaseUserManager implements UserManagerDAO { $db = $this->getConnection(); $sql = "DELETE FROM users WHERE email = :email"; - $command = $db->prepare($sql); - if (!$command) { - throw new RuntimeException( - "Benutzer konnte nicht gelöscht werden." - ); - } - $command->execute([ ":email" => $email ]); @@ -256,8 +175,7 @@ class DatabaseUserManager implements UserManagerDAO { return $command->rowCount() > 0; } catch (PDOException $e) { - throw new RuntimeException($e->getMessage()); + throw new RuntimeException("Benutzer konnte nicht gelöscht werden."); } } - } \ No newline at end of file -- 2.47.3 From 0e032ae02980f54ad13089412036a8c0713867b2 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 23:22:16 +0200 Subject: [PATCH 06/12] Fehlerbehebung Passwort speichern --- php/controller/login-controller.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/php/controller/login-controller.php b/php/controller/login-controller.php index 348e301..c034dcb 100644 --- a/php/controller/login-controller.php +++ b/php/controller/login-controller.php @@ -1,9 +1,8 @@ Date: Fri, 5 Jun 2026 23:25:49 +0200 Subject: [PATCH 07/12] Fehlerbehebung Passwort speichern --- content/deleteAccount.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/deleteAccount.php b/content/deleteAccount.php index c9e0a12..6f02a18 100644 --- a/content/deleteAccount.php +++ b/content/deleteAccount.php @@ -1,11 +1,12 @@ Date: Fri, 5 Jun 2026 23:42:06 +0200 Subject: [PATCH 08/12] =?UTF-8?q?Passwortab=C3=A4nderung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/controller/profile-controller.php | 6 +++--- php/controller/register-controller.php | 6 +++--- php/model/UserManager.php | 2 +- php/validator/user-validator.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/php/controller/profile-controller.php b/php/controller/profile-controller.php index 4228a22..e183b20 100644 --- a/php/controller/profile-controller.php +++ b/php/controller/profile-controller.php @@ -38,15 +38,15 @@ try { $_GET["edit"] = "1"; } elseif (!userNameValidator($vorname)) { - $error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten."; + $error = "Der Vorname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten."; $_GET["edit"] = "1"; } elseif (!userNameValidator($nachname)) { - $error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten."; + $error = "Der Nachname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten."; $_GET["edit"] = "1"; } elseif (!userOptionalPasswordValidator($password)) { - $error = "Das Passwort muss 8 bis 72 Zeichen lang sein."; + $error = "Das Passwort muss 5 bis 12 Zeichen lang sein."; $_GET["edit"] = "1"; } else { diff --git a/php/controller/register-controller.php b/php/controller/register-controller.php index db3dce0..3224eff 100644 --- a/php/controller/register-controller.php +++ b/php/controller/register-controller.php @@ -15,11 +15,11 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { if (!userEmailValidator($email)) { $error = "Bitte gib eine gültige E-Mail-Adresse ein."; } elseif (!userNameValidator($vorname)) { - $error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten."; + $error = "Der Vorname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten."; } elseif (!userNameValidator($nachname)) { - $error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten."; + $error = "Der Nachname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten."; } elseif (!userPasswordValidator($plainPassword)) { - $error = "Das Passwort muss 8 bis 72 Zeichen lang sein."; + $error = "Das Passwort muss 5 bis 12 Zeichen lang sein."; } else { try { $dao = UserManager::getInstance(); diff --git a/php/model/UserManager.php b/php/model/UserManager.php index 0cca25d..3068087 100644 --- a/php/model/UserManager.php +++ b/php/model/UserManager.php @@ -23,7 +23,7 @@ class UserManager { "mustermann@web.de", "Max", "Mustermann", - password_hash("test123", PASSWORD_DEFAULT) + password_hash("test12345", PASSWORD_DEFAULT) ); } diff --git a/php/validator/user-validator.php b/php/validator/user-validator.php index 80dd996..0f3bc40 100644 --- a/php/validator/user-validator.php +++ b/php/validator/user-validator.php @@ -3,7 +3,7 @@ function userNameValidator($name) { $name = trim($name); - $namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,50}$/u'; + $namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,20}$/u'; return preg_match($namePattern, $name) === 1; } @@ -20,7 +20,7 @@ function userPasswordValidator($password) { $zeichenAnzahl = mb_strlen($password); - return $zeichenAnzahl >= 8 && $zeichenAnzahl <= 72; + return $zeichenAnzahl >= 5 && $zeichenAnzahl <= 12; } function userOptionalPasswordValidator($password) -- 2.47.3 From 36ec2a539c0f8d440f99ee89d646c3c3f9c47478 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Fri, 5 Jun 2026 23:47:24 +0200 Subject: [PATCH 09/12] =?UTF-8?q?LocalUserManager=20=C3=BCberall=20entfern?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/controller/createArticle-controller.php | 1 - php/controller/profileArticles-controller.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/php/controller/createArticle-controller.php b/php/controller/createArticle-controller.php index 5e72e68..a39a409 100644 --- a/php/controller/createArticle-controller.php +++ b/php/controller/createArticle-controller.php @@ -3,7 +3,6 @@ SESSION_START(); require_once '../model/LocalArticleManager.php'; require_once '../model/ArticleManager.php'; require_once '../validator/article-validator.php'; -require_once "../model/LocalUserManager.php"; if ($_SERVER["REQUEST_METHOD"] === "POST") { $_SESSION["old_title"] = $_POST["title"] ?? ''; diff --git a/php/controller/profileArticles-controller.php b/php/controller/profileArticles-controller.php index 49a9ea1..9842500 100644 --- a/php/controller/profileArticles-controller.php +++ b/php/controller/profileArticles-controller.php @@ -5,10 +5,10 @@ require_once 'php/model/Article.php'; require_once 'php/model/ArticleManager.php'; -require_once "../model/LocalUserManager.php"; +require_once "php/model/UserManager.php"; try { - $dao = new LocalUserManager(); + $dao = UserManager::getInstance(); $user = $dao->findUser($_SESSION["user_email"] ?? ""); $author = $user["email"]; -- 2.47.3 From e7a5c2b352cd7e3df5f2c9bdfd7b51eb8cf98b22 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Mon, 8 Jun 2026 20:10:11 +0200 Subject: [PATCH 10/12] =?UTF-8?q?Kommentare=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../315cb5c9-2b0f-435b-b602-59823b160908.xml | 1833 ----------------- .../storage_v2/_src_/schema/main.uQUzAA.meta | 2 - .../a0abcd0a-1d6f-40e4-88be-f442bcb431ba.xml | 1833 ----------------- .../storage_v2/_src_/schema/main.uQUzAA.meta | 2 - content/deleteAccount.php | 28 +- php/model/DatabaseUserManager.php | 80 + php/validator/user-validator.php | 42 + 7 files changed, 141 insertions(+), 3679 deletions(-) delete mode 100644 .idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908.xml delete mode 100644 .idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908/storage_v2/_src_/schema/main.uQUzAA.meta delete mode 100644 .idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba.xml delete mode 100644 .idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba/storage_v2/_src_/schema/main.uQUzAA.meta diff --git a/.idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908.xml b/.idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908.xml deleted file mode 100644 index 4fccad1..0000000 --- a/.idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908.xml +++ /dev/null @@ -1,1833 +0,0 @@ - - - - - 3.51.1 - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - window - - - 1 - - - 1 - - - 1 - - - - 1 - 1 - - - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - - - window - - - window - - - window - - - - - - 1 - 1 - - - 1 - 1 - - - 1 - - - window - - - - 1 - - - window - - - 1 - - - 1 - 1 - - - - - - 1 - - - - - 1 - - - 1 - - - window - - - window - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - window - - - 1 - window - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - window - - - 1 - window - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - window - - - window - - - window - - - - window - - - window - - - window - - - window - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - aggregate - - - 1 - - - 1 - - - - - - 1 - 1 - - - window - - - aggregate - - - 1 - 1 - - - window - - - 1 - - - aggregate - - - window - - - window - - - 1 - - - 1 - - - - - - - - window - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - - 1 - - - 1 - - - - - window - - - 1 - - - 1 - - - - - - 1 - - - 1 - - - window - - - 1 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - - - 1 - - - - aggregate - - - - 1 - 1 - - - window - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - window - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - window - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - aggregate - - - aggregate - - - 1 - - - 1 - 2026-06-05.07:13:27 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - R - - - R - - - R - - - R - - - R - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 1 -
- - 1 - TEXT|0s - - - 2 - TEXT|0s - - - 3 - TEXT|0s - - - 4 - INT|0s - - - 5 - TEXT|0s - -
-
\ No newline at end of file diff --git a/.idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908/storage_v2/_src_/schema/main.uQUzAA.meta deleted file mode 100644 index 8dab49c..0000000 --- a/.idea/dataSources/315cb5c9-2b0f-435b-b602-59823b160908/storage_v2/_src_/schema/main.uQUzAA.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:main -! [0, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba.xml b/.idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba.xml deleted file mode 100644 index 9fc8217..0000000 --- a/.idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba.xml +++ /dev/null @@ -1,1833 +0,0 @@ - - - - - 3.51.1 - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - window - - - 1 - - - 1 - - - 1 - - - - 1 - 1 - - - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - - - window - - - window - - - window - - - - - - 1 - 1 - - - 1 - 1 - - - 1 - - - window - - - - 1 - - - window - - - 1 - - - 1 - 1 - - - - - - 1 - - - - - 1 - - - 1 - - - window - - - window - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - window - - - 1 - window - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - window - - - 1 - window - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - window - - - window - - - window - - - - window - - - window - - - window - - - window - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - aggregate - - - 1 - - - 1 - - - - - - 1 - 1 - - - window - - - aggregate - - - 1 - 1 - - - window - - - 1 - - - aggregate - - - window - - - window - - - 1 - - - 1 - - - - - - - - window - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - - 1 - - - 1 - - - - - window - - - 1 - - - 1 - - - - - - 1 - - - 1 - - - window - - - 1 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - - - 1 - - - - aggregate - - - - 1 - 1 - - - window - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - window - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - window - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - aggregate - - - aggregate - - - 1 - - - 1 - 2026-06-05.07:12:20 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - R - - - R - - - R - - - R - - - R - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 1 -
- - 1 - TEXT|0s - - - 2 - TEXT|0s - - - 3 - TEXT|0s - - - 4 - INT|0s - - - 5 - TEXT|0s - -
-
\ No newline at end of file diff --git a/.idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba/storage_v2/_src_/schema/main.uQUzAA.meta deleted file mode 100644 index 8dab49c..0000000 --- a/.idea/dataSources/a0abcd0a-1d6f-40e4-88be-f442bcb431ba/storage_v2/_src_/schema/main.uQUzAA.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:main -! [0, 0, null, null, -2147483648, -2147483648] diff --git a/content/deleteAccount.php b/content/deleteAccount.php index 6f02a18..8d42198 100644 --- a/content/deleteAccount.php +++ b/content/deleteAccount.php @@ -2,19 +2,29 @@ require_once "php/model/UserManager.php"; -$dao = UserManager::getInstance(); - /* Deregistrierung Funktion: Entfernt User aus der Datenbank und beendet die Session */ -if (isset($_SESSION["user_email"])) { - $dao->deleteUser($_SESSION["user_email"]); -} +try { -$_SESSION = []; -session_destroy(); + $dao = UserManager::getInstance(); -header("Location: index.php"); -exit(); \ No newline at end of file + if (isset($_SESSION["user_email"])) { + $dao->deleteUser($_SESSION["user_email"]); + } + + $_SESSION = []; + session_destroy(); + + header("Location: index.php"); + exit(); + +} catch (Exception $e) { + + $_SESSION["message"] = "internal_error"; + + header("Location: index.php?pfad=profile"); + exit(); +} \ No newline at end of file diff --git a/php/model/DatabaseUserManager.php b/php/model/DatabaseUserManager.php index a985160..4e04ae5 100644 --- a/php/model/DatabaseUserManager.php +++ b/php/model/DatabaseUserManager.php @@ -2,10 +2,24 @@ require_once "UserManagerDAO.php"; +/** + * Klasse für den Zugriff auf Benutzerdaten über eine SQLite-Datenbank. + * + * Diese Klasse verwendet PDO, Prepared Statements und speichert + * Benutzerdaten in der Datei db/users.db. + */ class DatabaseUserManager implements UserManagerDAO { private static $instance = null; + /** + * Konstruktor. + * + * Erstellt die Benutzerdatenbank und die Tabelle users, + * falls diese noch nicht existieren. + * + * @throws RuntimeException wenn die Datenbank nicht erstellt werden kann + */ public function __construct() { try { @@ -27,6 +41,13 @@ class DatabaseUserManager implements UserManagerDAO { } } + /** + * Baut eine Verbindung zur SQLite-Datenbank auf. + * + * @return PDO Datenbankverbindung + * + * @throws RuntimeException wenn keine Verbindung hergestellt werden kann + */ private function getConnection() { try { @@ -42,6 +63,11 @@ class DatabaseUserManager implements UserManagerDAO { } } + /** + * Gibt die Singleton-Instanz des DatabaseUserManagers zurück. + * + * @return DatabaseUserManager Instanz des DatabaseUserManagers + */ public static function getInstance() { if (self::$instance == null) { @@ -51,6 +77,16 @@ class DatabaseUserManager implements UserManagerDAO { return self::$instance; } + /** + * Sucht einen Benutzer anhand seiner E-Mail-Adresse. + * + * @param string $email E-Mail-Adresse des Benutzers + * + * @return array|null Benutzerdaten als Array oder null, + * wenn kein Benutzer gefunden wurde + * + * @throws RuntimeException wenn der Benutzer nicht geladen werden kann + */ public function findUser($email) { try { @@ -72,6 +108,22 @@ class DatabaseUserManager implements UserManagerDAO { } } + /** + * Fügt einen neuen Benutzer in die Datenbank ein. + * + * Die Speicherung erfolgt innerhalb einer Transaktion. + * Doppelte E-Mail-Adressen werden durch den Primary Key verhindert. + * + * @param string $email E-Mail-Adresse des Benutzers + * @param string $vorname Vorname des Benutzers + * @param string $nachname Nachname des Benutzers + * @param string $password Passwort-Hash des Benutzers + * + * @return void + * + * @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird + * @throws RuntimeException wenn der Benutzer nicht gespeichert werden kann + */ public function addUser($email, $vorname, $nachname, $password) { try { @@ -107,6 +159,24 @@ class DatabaseUserManager implements UserManagerDAO { } } + /** + * Aktualisiert die Daten eines bestehenden Benutzers. + * + * Optional kann zusätzlich das Passwort geändert werden. + * Wenn kein neues Passwort übergeben wird, bleibt das alte Passwort erhalten. + * + * @param string $oldEmail Aktuelle E-Mail-Adresse des Benutzers + * @param string $newEmail Neue E-Mail-Adresse des Benutzers + * @param string $vorname Neuer Vorname des Benutzers + * @param string $nachname Neuer Nachname des Benutzers + * @param string|null $password Neues Passwort oder null + * + * @return bool true, wenn der Benutzer aktualisiert wurde, + * sonst false + * + * @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird + * @throws RuntimeException wenn der Benutzer nicht aktualisiert werden kann + */ public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) { try { @@ -160,6 +230,16 @@ class DatabaseUserManager implements UserManagerDAO { } } + /** + * Löscht einen Benutzer anhand seiner E-Mail-Adresse. + * + * @param string $email E-Mail-Adresse des zu löschenden Benutzers + * + * @return bool true, wenn der Benutzer gelöscht wurde, + * sonst false + * + * @throws RuntimeException wenn der Benutzer nicht gelöscht werden kann + */ public function deleteUser($email) { try { diff --git a/php/validator/user-validator.php b/php/validator/user-validator.php index 0f3bc40..0f789cf 100644 --- a/php/validator/user-validator.php +++ b/php/validator/user-validator.php @@ -1,5 +1,15 @@ = 5 && $zeichenAnzahl <= 12; } +/** + * Prüft ein optionales Passwort. + * + * Ein leeres Passwort ist erlaubt und bedeutet, + * dass das bestehende Passwort unverändert bleibt. + * Falls ein Passwort angegeben wurde, wird es + * mit den normalen Passwortregeln geprüft. + * + * @param string|null $password Zu prüfendes Passwort + * + * @return bool true wenn das Passwort gültig oder leer ist, + * sonst false + */ function userOptionalPasswordValidator($password) { if (!isset($password) || $password === '') { -- 2.47.3 From 475836606322785c0aaa9503755b8ed72d8d4a3b Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Mon, 8 Jun 2026 20:18:08 +0200 Subject: [PATCH 11/12] Refactoring --- index.php | 4 ++-- .../controller/deleteAccount-controller.php | 0 content/logout.php => php/controller/logout-controller.php | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename content/deleteAccount.php => php/controller/deleteAccount-controller.php (100%) rename content/logout.php => php/controller/logout-controller.php (100%) diff --git a/index.php b/index.php index cd4ea48..d02673d 100644 --- a/index.php +++ b/index.php @@ -17,12 +17,12 @@ if ($pfad === "register") { } if ($pfad === "logout") { - include_once "content/logout.php"; + include_once "content/logout-controller.php"; exit(); } if ($pfad === "deleteAccount") { - include_once "content/deleteAccount.php"; + include_once "content/deleteAccount-controller.php"; exit(); } ?> diff --git a/content/deleteAccount.php b/php/controller/deleteAccount-controller.php similarity index 100% rename from content/deleteAccount.php rename to php/controller/deleteAccount-controller.php diff --git a/content/logout.php b/php/controller/logout-controller.php similarity index 100% rename from content/logout.php rename to php/controller/logout-controller.php -- 2.47.3 From a5650f272077d6dae1a29a7e5944bc997634eb16 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Mon, 8 Jun 2026 20:20:06 +0200 Subject: [PATCH 12/12] Reviewanpassungen --- php/controller/login-controller.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/php/controller/login-controller.php b/php/controller/login-controller.php index c034dcb..28090cf 100644 --- a/php/controller/login-controller.php +++ b/php/controller/login-controller.php @@ -2,7 +2,6 @@ require_once "php/model/UserManager.php"; -$dao = UserManager::getInstance(); $error = null; /* @@ -11,20 +10,28 @@ $error = null; */ if ($_SERVER["REQUEST_METHOD"] === "POST") { - $email = $_POST["email"] ?? ""; - $password = $_POST["password"] ?? ""; + try { - $user = $dao->findUser($email); + $dao = UserManager::getInstance(); - if ($user && password_verify($password, $user["password"])) { + $email = $_POST["email"] ?? ""; + $password = $_POST["password"] ?? ""; - $_SESSION["user"] = $user["vorname"] . " " . $user["nachname"]; - $_SESSION["user_email"] = $user["email"]; + $user = $dao->findUser($email); - header("Location: index.php"); - exit(); + if ($user && password_verify($password, $user["password"])) { - } else { - $error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben."; + $_SESSION["user"] = $user["vorname"] . " " . $user["nachname"]; + $_SESSION["user_email"] = $user["email"]; + + header("Location: index.php"); + exit(); + + } else { + $error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben."; + } + + } catch (Exception $e) { + $error = "Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut."; } } \ No newline at end of file -- 2.47.3