diff --git a/CSS/style.css b/CSS/style.css index 6fda564..b1097a0 100644 --- a/CSS/style.css +++ b/CSS/style.css @@ -150,32 +150,63 @@ a { border-radius: 10px; } -.login-container { - position: absolute; - top: 200px; +.form-container { background-color: #BAC8D4; - width: 900px; - height: 450px; + width: 100%; + max-width: 400px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; - justify-content: center; box-sizing: border-box; + padding: 32px 24px 24px 24px; + margin: 32px auto; } - -.event-container { - position: absolute; - top: 200px; - background-color: #BAC8D4; - width: 900px; - height: 450px; - border-radius: 10px; +.form-horizontal { + width: 100%; display: flex; flex-direction: column; - align-items: center; - justify-content: center; + gap: 12px; + margin-bottom: 10px; +} +.form-horizontal label { + margin-bottom: 2px; +} +.form-horizontal input[type="text"], +.form-horizontal input[type="email"], +.form-horizontal input[type="password"] { + width: 100%; + padding: 8px 10px; + border: 1px solid #BAC8D4; + border-radius: 4px; + font-size: 1rem; box-sizing: border-box; + background: #fff; +} +.form-horizontal button { + width: 100%; + padding: 10px 0; + border: none; + border-radius: 4px; + background: #4d4d4d; + color: #fff; + font-size: 1rem; + margin-top: 8px; + cursor: pointer; + transition: background 0.2s; +} +.form-horizontal button:hover { + background: #333; +} +.login-error, .form-error { + background: #ffe0e0; + color: #b30000; + border: 1px solid #ffb3b3; + border-radius: 6px; + padding: 10px 16px; + margin-bottom: 18px; + width: 100%; + text-align: center; } @media (max-width: 600px) { diff --git a/Controller/AuthController.php b/Controller/AuthController.php index 79dab84..db50723 100644 --- a/Controller/AuthController.php +++ b/Controller/AuthController.php @@ -63,14 +63,14 @@ class AuthController public function register() { $data = [ - 'first_name' => $_POST['vorname'] ?? '', - 'last_name' => $_POST['nachname'] ?? '', - 'street' => $_POST['strasse'] ?? '', - 'house_number' => $_POST['hausnr'] ?? '', - 'postal_code' => $_POST['plz'] ?? '', - 'city' => $_POST['ort'] ?? '', - 'country' => $_POST['land'] ?? '', - 'phone' => $_POST['tel'] ?? '', + 'first_name' => $_POST['first_name'] ?? '', + 'last_name' => $_POST['last_name'] ?? '', + 'street' => $_POST['street'] ?? '', + 'house_number' => $_POST['house_number'] ?? '', + 'postal_code' => $_POST['postal_code'] ?? '', + 'city' => $_POST['city'] ?? '', + 'country' => $_POST['country'] ?? '', + 'phone' => $_POST['phone'] ?? '', 'email' => $_POST['email'] ?? '', 'password' => $_POST['password'] ?? '', 'password_repeat' => $_POST['password_repeat'] ?? '', @@ -80,13 +80,15 @@ class AuthController $result = $this->model->register($data); if ($result === true) { - $this->view->setVars(['success' => 'Registrierung erfolgreich!']); - $this->view->render('Auth/showLoginForm'); - exit; + $this->view->setDoMethodName('showRegistrationSuccess'); } else { - $errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen."; + if (is_array($result)) { + $errors['register'] = implode('
', $result); + } else { + $errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen."; + } $this->view->setVars(['errors' => $errors, 'validData' => $data]); - $this->view->render('Auth/showRegistrationForm'); + $this->view->setDoMethodName('showRegistrationForm'); } } diff --git a/Controller/RegisterController.php b/Controller/RegisterController.php deleted file mode 100644 index eb2059b..0000000 --- a/Controller/RegisterController.php +++ /dev/null @@ -1,10 +0,0 @@ -pwRequirementCheck($data['password']) !== true) { - return "Passwort muss mindestens 8 Zeichen lang sein und mindestens ein Großbuchstabe, ein Kleinbuchstabe, eine Zahl und ein Sonderzeichen enthalten."; + $pwCheck = $this->pwRequirementCheck($data['password']); + if ($pwCheck !== true) { + return $pwCheck; // Array mit spezifischen Fehlern zurückgeben } $hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT); @@ -220,16 +221,16 @@ class AuthModel extends Database public function pwRequirementCheck($password){ $error = []; - if(strlen($password) <= 8) - $error[] = "min 8 Charackter"; + if(strlen($password) < 8) + $error[] = "Passwort: mindestens 8 Zeichen"; if(!preg_match("/[A-Z]/", $password)) - $error[] = "min one large Character"; + $error[] = "Passwort: mindestens ein Großbuchstabe"; if(!preg_match("/[a-z]/", $password)) - $error[] = "min one small charakter"; + $error[] = "Passwort: mindestens ein Kleinbuchstabe"; if(!preg_match("/[0-9]/", $password)) - $error[] = "min one number"; - if(!preg_match("[^a-zA-Z0-9\s]", $password)); - $error[] = "min one special character"; + $error[] = "Passwort: mindestens eine Zahl"; + if(!preg_match("/[^a-zA-Z0-9\s]/", $password)) + $error[] = "Passwort: mindestens ein Sonderzeichen"; if(empty($error)) return true; diff --git a/Views/Auth/showLoginForm.phtml b/Views/Auth/showLoginForm.phtml index a6e923f..2be97ab 100644 --- a/Views/Auth/showLoginForm.phtml +++ b/Views/Auth/showLoginForm.phtml @@ -1,8 +1,8 @@
-
+

Anmelden

- +
@@ -11,7 +11,7 @@ - +
Passwort vergessen? diff --git a/Views/Auth/showRegistrationForm.phtml b/Views/Auth/showRegistrationForm.phtml index e9367f6..c3de7de 100644 --- a/Views/Auth/showRegistrationForm.phtml +++ b/Views/Auth/showRegistrationForm.phtml @@ -1,64 +1,37 @@
- diff --git a/Views/Auth/showRegistrationSuccess.phtml b/Views/Auth/showRegistrationSuccess.phtml new file mode 100644 index 0000000..c4ee503 --- /dev/null +++ b/Views/Auth/showRegistrationSuccess.phtml @@ -0,0 +1,14 @@ +
+ +
+ + \ No newline at end of file diff --git a/Views/header.phtml b/Views/header.phtml index 25b35c3..14f6b70 100644 --- a/Views/header.phtml +++ b/Views/header.phtml @@ -12,15 +12,15 @@