Primer version funcional
This commit is contained in:
25
login.php
Executable file
25
login.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require_once __DIR__ . '/config/config.php';
|
||||
require_once __DIR__ . '/core/Database.php';
|
||||
require_once __DIR__ . '/core/Auth.php';
|
||||
|
||||
require_once __DIR__ . '/models/User.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = trim($_POST['username'] ?? '');
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
$user = User::findByUsername($username);
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
Auth::login($user);
|
||||
header('Location: /dashboard.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Credenciales incorrectas';
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/views/auth/login.php';
|
||||
Reference in New Issue
Block a user