Permet à l'utilisateur de se connecter

This commit is contained in:
2022-11-22 09:30:43 +01:00
parent 53038a5022
commit b4f9d31c2e
11 changed files with 265 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Silex\Controller;
use Silex\DI\DI;
use Silex\Http\HttpResponse;
class SecurityController
{
public function login(DI $di): HttpResponse
{
$fail = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$success = $di->getSecurity()->initLogin($_POST['login'], $_POST['password']);
if ($success) {
http_response_code(303);
header('Location: ' . $di->getRouter()->url(''));
exit();
}
var_dump($success);
$fail = !$success;
}
return HttpResponse::found('login', ['fail' => $fail]);
}
}