Update profile-controller.php
This commit is contained in:
@@ -5,6 +5,7 @@ require_once "php/model/Article.php";
|
|||||||
require_once "php/model/ArticleManager.php";
|
require_once "php/model/ArticleManager.php";
|
||||||
require_once "php/model/CommentManager.php";
|
require_once "php/model/CommentManager.php";
|
||||||
require_once "php/validator/user-validator.php";
|
require_once "php/validator/user-validator.php";
|
||||||
|
require_once "includes/csrf.php";
|
||||||
|
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["saveProfile"])) {
|
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["saveProfile"])) {
|
||||||
|
|
||||||
$oldEmail = $_SESSION["user_email"];
|
$oldEmail = $_SESSION["user_email"];
|
||||||
|
|
||||||
$newEmail = trim($_POST["email"] ?? "");
|
$newEmail = trim($_POST["email"] ?? "");
|
||||||
@@ -34,7 +36,12 @@ try {
|
|||||||
$nachname = trim($_POST["nachname"] ?? "");
|
$nachname = trim($_POST["nachname"] ?? "");
|
||||||
$password = $_POST["password"] ?? "";
|
$password = $_POST["password"] ?? "";
|
||||||
|
|
||||||
if (!userEmailValidator($newEmail)) {
|
if (!csrf_verify()) {
|
||||||
|
// CSRF-Token prüfen, bevor irgendeine Änderung vorgenommen wird
|
||||||
|
$error = "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu und versuche es erneut.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} elseif (!userEmailValidator($newEmail)) {
|
||||||
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||||
$_GET["edit"] = "1";
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user