Merge branch 'main' of https://git.bib.de/PBBFA23AHR/kurs-app
This commit is contained in:
commit
c46e3ddb58
@ -31,11 +31,19 @@ class UserController{
|
||||
}
|
||||
|
||||
public function showUserRegisterForm(){
|
||||
if (!isset($this->errors)) {
|
||||
$this->errors = [];
|
||||
}
|
||||
if (!isset($this->validData)) {
|
||||
$this->validData = [];
|
||||
}
|
||||
|
||||
$this->view->setVars([
|
||||
'labels' => $this->labels,
|
||||
'errors' => $this->errors,
|
||||
'validData' => $this->validData
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function showUserRegisterConfirmation(){
|
||||
@ -98,15 +106,27 @@ class UserController{
|
||||
}
|
||||
|
||||
public function register(){
|
||||
$this->validateForm();
|
||||
|
||||
if(count($this->errors) > 0){
|
||||
$this->view->setDoMethodName("showUserRegisterForm");
|
||||
$this->showUserRegisterForm();
|
||||
} else{
|
||||
$this->db->createUser($_POST);
|
||||
$this->login();
|
||||
}
|
||||
}
|
||||
|
||||
public function login(){
|
||||
$user = $this->db->getUserByEmail($_POST["email"]);
|
||||
|
||||
$this->validateLoginForm();
|
||||
|
||||
if(!$user){
|
||||
echo "Benutzer nicht gefunden";
|
||||
$this->loginErrors['email'] = "Email oder Passwort ist falsch";
|
||||
$this->view->setDoMethodName("showUserLoginForm");
|
||||
$this->showUserLoginForm();
|
||||
return;
|
||||
}
|
||||
|
||||
$hash = hash('sha256', $_POST["password"] . $user["salt"]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user