From 6de86c3143aaf36810cd09d30831e811a8692490 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Tue, 2 Jun 2026 00:16:53 +0200 Subject: [PATCH] $_SESSION["user_email"] --- php/controller/createArticle-controller.php | 11 ++--------- php/controller/profile-controller.php | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/php/controller/createArticle-controller.php b/php/controller/createArticle-controller.php index aaefb25..214101e 100644 --- a/php/controller/createArticle-controller.php +++ b/php/controller/createArticle-controller.php @@ -5,9 +5,6 @@ require_once '../model/ArticleManager.php'; require_once '../validator/article-validator.php'; require_once "../model/LocalUserDAO.php"; -try{ - $dao = new LocalUserDAO(); - $user = $dao->findUser($_SESSION["user_email"] ?? ""); if ($_SERVER["REQUEST_METHOD"] === "POST") { $_SESSION["old_title"] = $_POST["title"] ?? ''; $_SESSION["old_content"] = $_POST["content"] ?? ''; @@ -21,7 +18,7 @@ try{ } else { $title = $_POST["title"]; $content = $_POST["content"]; - $author = $user["email"]; + $author = $_SESSION["user_email"]; $category = $_POST["category"]; $tags = $_POST['tags'] ?? ''; @@ -86,11 +83,7 @@ try{ exit(); } } -} catch (Exception $e) { - $_SESSION["message"] = "internal_error"; - header("location: ../../index.php?pfad=createArticle"); - exit(); -} + ?> \ No newline at end of file diff --git a/php/controller/profile-controller.php b/php/controller/profile-controller.php index 5cf6126..daf511a 100644 --- a/php/controller/profile-controller.php +++ b/php/controller/profile-controller.php @@ -14,7 +14,7 @@ if (!isset($_SESSION["user"])) { try { $user = $dao->findUser($_SESSION["user_email"] ?? ""); $articleManager = ArticleManager::getInstance(); - $userArticles = $articleManager->getArticlesByAuthor($user); + $userArticles = $articleManager->getArticlesByAuthor($_SESSION["user_email"]); if(!isset($userArticles)) { $_SESSION["message"] = "user_has_no_articles"; }