Compare commits

..

No commits in common. "1204c89ca3f9d3faa96c5c7e3c9fdda3653763f8" and "6083a3f1c4d48ed4d9bd8432b8481be44d4a32d0" have entirely different histories.

5 changed files with 9 additions and 62 deletions

View File

@ -20,6 +20,7 @@ body {
}
h1 {
margin: 10px;
color: var(--brand-white);
font-size: var(--font-size-title-h1);
}

View File

@ -19,7 +19,7 @@ class UserController{
}
public function showUserRegisterConfirmation(){
public function showUserConfirmation(){
}
@ -27,20 +27,10 @@ class UserController{
}
public function showUserLoginConfirmation(){
$userId = $this->getCurrentUserId();
$user = null;
var_dump($user . "user");
if($userId){
$user = $this->db->getUserById($userId);
}
include 'Views/User/showUserLoginConfirmation.phtml';
}
public function register(){
$this->db->createUser($_POST);
$this->view->setDoMethodName("showUserRegisterConfirmation");
$this->showUserRegisterConfirmation();
$this->view->setDoMethodName("showUserConfirmation");
$this->showUserConfirmation();
}
public function login(){
@ -53,32 +43,13 @@ class UserController{
$hash = hash('sha256', $_POST["password"] . $user["salt"]);
if($hash == $user["passwort"]){
$this->setUserSession($user);
$this->showUserLoginConfirmation();
$_SESSION["user_id"] = $user["id"];
$_SESSION["user_role"] = $user["role"];
echo "Login ergolgreich";
}else{
echo "Falsches Passwort";
}
}
public function setUserSession(array $user){
$_SESSION["user_id"] = $user["id"];
$_SESSION["user_role"] = $user["role"];
}
public function clearUserSession(){
unset($_SESSION["user_id"], $_SESSION["user_role"]);
}
public function logout(){
$this->clearUserSession();
echo "Erfolgreich ausgeloggt";
}
public function isUserLoggenIn(){
return isset($_SESSION["user_id"]);
}
public function getCurrentUserId(){
return $_SESSION["user_id"] ?? null;
}
}

View File

@ -28,8 +28,8 @@ class UserModel extends Database
$sth = $pdo->prepare($sql);
$sth->execute([
":guid" => $guid,
":name" => $values["lastname"],
":firstname" => $values["name"],
":name" => $values["name"],
":firstname" => $values["lastname"],
":email" => $values["email"],
":password" => $hash,
":salt" => $salt,
@ -51,12 +51,4 @@ class UserModel extends Database
return $sth->fetch();
}
public function getUserById($id){
$pdo = $this->linkDB();
$sql = "SELECT * FROM user WHERE id = :id";
$sth = $pdo->prepare($sql);
$sth->execute([":id" => $id]);
return $sth->fetch();
}
}

View File

@ -1,17 +0,0 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<?php if ($user): ?>
<p>Hallo, <?= htmlspecialchars($user['vorname']) ?> <?= htmlspecialchars($user['name']) ?>!</p>
<?php else: ?>
<p>Benutzerdaten konnten nicht geladen werden.</p>
<?php endif; ?>
<h1>Sie haben sich erfolgreich angemeldet</h1>
<?php
include dirname(__DIR__).'/footer.phtml';
?>