Merge branch 'main' of https://git.bib.de/PBBFA23AHR/kurs-app
This commit is contained in:
@@ -5,23 +5,51 @@ namespace Blog\Controller;
|
||||
use Blog\Model\UserModel;
|
||||
|
||||
class UserController{
|
||||
private $view;
|
||||
private $view;
|
||||
private $db;
|
||||
private $validData = array();
|
||||
private $errors = array();
|
||||
private $labels = array("name" => "Name", "email" => "E-Mail-Adresse", "content" => "Nachricht");
|
||||
|
||||
public function __construct($view){
|
||||
$this->db = new UserModel();
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function showUserForm(){
|
||||
public function showUserRegisterForm(){
|
||||
|
||||
}
|
||||
|
||||
public function showUserConfirmation(){
|
||||
|
||||
}
|
||||
|
||||
public function showUserLoginForm(){
|
||||
|
||||
}
|
||||
|
||||
public function register(){
|
||||
$this->db->createUser($this->labels);
|
||||
$this->db->createUser($_POST);
|
||||
$this->view->setDoMethodName("showUserConfirmation");
|
||||
$this->showUserConfirmation();
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user