diff --git a/CSS/style.css b/CSS/style.css index d56777e..08bea58 100644 --- a/CSS/style.css +++ b/CSS/style.css @@ -152,4 +152,8 @@ form select { .hover:hover{ opacity: .75; text-decoration: none; +} +/*TODO Muss in die form.css übernommen werden*/ +main a{ + color: var(--brand-white); } \ No newline at end of file diff --git a/Controller/UserController.php b/Controller/UserController.php index 5cb2c1d..463c83a 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -15,7 +15,7 @@ class UserController{ $this->view = $view; } - public function showUserForm(){ + public function showUserRegisterForm(){ } @@ -34,6 +34,22 @@ class UserController{ } public function login(){ - + $user = $this->db->getUserByEmail($_POST["email"]); + + if(!$user){ + echo "Benutzer nicht gefunden"; + } + + $hash = hash('sha256', $_POST["password"] . $user["salt"]); + + if($hash == $user["passwort"]){ + $_SESSION["user_id"] = $user["id"]; + $_SESSION["user_role"] = $user["role"]; + echo "Login ergolgreich"; + }else{ + echo "Falsches Passwort"; + } + + } } \ No newline at end of file diff --git a/Model/UserModel.php b/Model/UserModel.php index f3af5a4..ed2a2de 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -43,4 +43,12 @@ class UserModel extends Database return true; } + public function getUserByEmail($email){ + $pdo = $this->linkDB(); + $sql = "SELECT * FROM user WHERE email = :email"; + $sth = $pdo->prepare($sql); + $sth->execute([":email" => $email]); + return $sth->fetch(); + } + } \ No newline at end of file diff --git a/Views/User/showUserLoginForm.phtml b/Views/User/showUserLoginForm.phtml index d843462..e541dbf 100644 --- a/Views/User/showUserLoginForm.phtml +++ b/Views/User/showUserLoginForm.phtml @@ -13,8 +13,8 @@ - - + + diff --git a/Views/User/showUserForm.phtml b/Views/User/showUserRegisterForm.phtml similarity index 100% rename from Views/User/showUserForm.phtml rename to Views/User/showUserRegisterForm.phtml diff --git a/Views/header.phtml b/Views/header.phtml index a1ddec0..a21a709 100644 --- a/Views/header.phtml +++ b/Views/header.phtml @@ -20,7 +20,7 @@