Add MySQL schema dump for phpMyAdmin
This commit is contained in:
36
app/Controllers/AuthController.php
Normal file
36
app/Controllers/AuthController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Controller;
|
||||
use App\Core\Response;
|
||||
use App\Services\AuthService;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function showLogin(): Response
|
||||
{
|
||||
return $this->view('auth/login');
|
||||
}
|
||||
|
||||
public function login(): Response
|
||||
{
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
$auth = AuthService::getInstance();
|
||||
if ($auth->attempt($email, $password)) {
|
||||
return $this->redirect('/');
|
||||
}
|
||||
|
||||
return $this->view('auth/login', [
|
||||
'error' => 'Invalid credentials or inactive account.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(): Response
|
||||
{
|
||||
AuthService::getInstance()->logout();
|
||||
return $this->redirect('/login');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user