init Abgabe
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class Login {
|
||||
|
||||
public function index() {
|
||||
|
||||
$errors = [];
|
||||
|
||||
if (isset($_POST['submit'])) {
|
||||
// LoginModel erstellen
|
||||
$loginModel = Factory::createLoginModel();
|
||||
|
||||
// Werte aus POST setzen
|
||||
$loginModel->setEmail($_POST['email']);
|
||||
$loginModel->setPasswort($_POST['passwort']);
|
||||
// Login versuchen
|
||||
if ($loginModel->login()) {
|
||||
// Erfolgreicher Login → Weiterleitung zur Chat-Seite
|
||||
header("Location: " . PROJEKT_URL . "/chat");
|
||||
exit;
|
||||
} else {
|
||||
// Login fehlgeschlagen → Fehler abholen
|
||||
$errors = $loginModel->getErrors();
|
||||
}
|
||||
}
|
||||
|
||||
// View einbinden
|
||||
require_once(PROJEKT_VIEW_DIR . "/login/index.php");
|
||||
}
|
||||
|
||||
|
||||
public function logout() {
|
||||
|
||||
// Session leeren
|
||||
$_SESSION = [];
|
||||
|
||||
// Session-Cookie löschen
|
||||
if (ini_get("session.use_cookies")) {
|
||||
$params = session_get_cookie_params();
|
||||
setcookie(session_name(), '', time() - 42000,
|
||||
$params['path'], $params['domain'],
|
||||
$params['secure'], $params['httponly']
|
||||
);
|
||||
}
|
||||
|
||||
// Session zerstören
|
||||
session_destroy();
|
||||
|
||||
// Zur Login-Seite weiterleiten
|
||||
header("Location: " . PROJEKT_URL . "/Login");
|
||||
exit;
|
||||
}
|
||||
|
||||
public function registrieren() {
|
||||
|
||||
if (isset($_POST['submit'])) {
|
||||
$userObj = Factory::createBenutzerModel();
|
||||
$userObj->setValues($_POST);
|
||||
$userObj->insert();
|
||||
}
|
||||
|
||||
require_once(PROJEKT_VIEW_DIR . "/login/registrieren.php");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user