Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- declare(strict_types=1);
- require_once PATH . 'Models/UserModel.php';
- require_once PATH . 'Controllers/AbstractController.php';
- class LoginController extends AbstractController {
- public function __construct() {
- parent::__construct();
- $this->model = new UserModel($this->db);
- }
- /*
- public function login() : string {
- if ($this->method === 'GET') {
- return $this->render('login.twig', []);
- }
- $email = $_POST['email'] ?? '';
- $password = $_POST['password'] ?? '';
- if (empty($email) || empty($email)) {
- return $this->render('login.twig', ['error' => "Please provide your email and password."]);
- }
- $user = $this->model->getByEmail($email);
- if (isset($user) && password_verify($password, $user['password'])) {
- $_SESSION['userid'] = $user['id'];
- header('Location: index.php');
- }
- else {
- return $this->render('login.twig', ['error' => "Email and password did not match."]);
- }
- }
- */
- public function logout() : string {
- unset($_SESSION['user']);
- session_unset();
- session_destroy();
- return $this->render('login.twig', []);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement