add login system (in Bearbeitung)

This commit is contained in:
2025-06-18 11:17:02 +02:00
parent 47e6d11fad
commit f59491a327
6 changed files with 33 additions and 5 deletions

View File

@@ -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";
}
}
}