user change info + add hovers für buttons
This commit is contained in:
@@ -280,18 +280,18 @@ class UserController{
|
||||
}
|
||||
|
||||
$submitted = [
|
||||
'vorname' => trim($_POST['vorname'] ?? ''),
|
||||
'name' => trim($_POST['name'] ?? ''),
|
||||
'lastname' => trim($_POST['lastname'] ?? ''),
|
||||
'email' => trim($_POST['email'] ?? ''),
|
||||
'password' => trim($_POST['password'] ?? ''),
|
||||
];
|
||||
|
||||
$this->errors = [];
|
||||
if (strlen($submitted['name']) < 2) {
|
||||
$this->errors['name'] = 'Vorname muss mindestens 2 Zeichen haben.';
|
||||
if (strlen($submitted['vorname']) < 2) {
|
||||
$this->errors['vorname'] = 'Vorname muss mindestens 2 Zeichen haben.';
|
||||
}
|
||||
if (strlen($submitted['lastname']) < 2) {
|
||||
$this->errors['lastname'] = 'Nachname muss mindestens 2 Zeichen haben.';
|
||||
if (strlen($submitted['name']) < 2) {
|
||||
$this->errors['name'] = 'Nachname muss mindestens 2 Zeichen haben.';
|
||||
}
|
||||
if (!filter_var($submitted['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$this->errors['email'] = 'Ungültige E-Mail-Adresse.';
|
||||
@@ -303,24 +303,31 @@ class UserController{
|
||||
|
||||
if (count($this->errors) > 0) {
|
||||
$this->view->setVars([
|
||||
'labels' => $this->changeUserLabels,
|
||||
'validData' => $submitted,
|
||||
'errors' => $this->errors,
|
||||
'changeUserLabels' => $this->changeUserLabels,
|
||||
'validData' => $submitted,
|
||||
'errors' => $this->errors,
|
||||
]);
|
||||
return;
|
||||
$this->view->render('User/showUserChangeAccountSettings');
|
||||
return;
|
||||
}
|
||||
|
||||
$updateData = [];
|
||||
if ($submitted['name'] !== $currentUser['firstname']) {
|
||||
$updateData['firstname'] = $submitted['name']; // PHP name = DB firstname
|
||||
if ($submitted['vorname'] !== $currentUser['vorname']) {
|
||||
$updateData['vorname'] = $submitted['vorname'];
|
||||
}
|
||||
if ($submitted['lastname'] !== $currentUser['name']) {
|
||||
$updateData['name'] = $submitted['lastname']; // PHP lastname = DB name
|
||||
if ($submitted['name'] !== $currentUser['name']) {
|
||||
$updateData['name'] = $submitted['name'];
|
||||
}
|
||||
if ($submitted['email'] !== $currentUser['email']) {
|
||||
$updateData['email'] = $submitted['email'];
|
||||
}
|
||||
if ($submitted['password'] !== '') {
|
||||
// Passwort und Salt auf neu setzen
|
||||
$salt = bin2hex(random_bytes(16));
|
||||
$hash = hash('sha256', $submitted['password'] . $salt);
|
||||
$updateData['passwort'] = $hash;
|
||||
$updateData['salt'] = $salt;
|
||||
}
|
||||
|
||||
|
||||
if ($submitted['password'] !== '') {
|
||||
@@ -344,15 +351,21 @@ class UserController{
|
||||
$_SESSION['email'] = $updateData['email'] ?? $_SESSION['email'];
|
||||
$this->message = 'Änderungen erfolgreich gespeichert.';
|
||||
|
||||
echo "ok";
|
||||
|
||||
header("Location: index.php?controller=user&do=showUserAccountPage");
|
||||
exit();
|
||||
} else {
|
||||
$this->errors['general'] = 'Beim Speichern ist ein Fehler aufgetreten.';
|
||||
$this->view->setVars([
|
||||
'changeUserLabels' => $this->changeUserLabels,
|
||||
'validData' => $submitted,
|
||||
'errors' => $this->errors,
|
||||
]);
|
||||
$this->view->setDoMethodName('showUserChangeAccountSettings');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->render('User/showUserAccountPage');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user