Permet l'inscription d'utilisateurs
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Silex\Controller;
|
||||
|
||||
use Silex\DI\DI;
|
||||
use Silex\Http\HttpResponse;
|
||||
use Silex\Model\User;
|
||||
|
||||
class SecurityController
|
||||
{
|
||||
@@ -19,9 +20,23 @@ class SecurityController
|
||||
header('Location: ' . $di->getRouter()->url(''));
|
||||
exit();
|
||||
}
|
||||
var_dump($success);
|
||||
$fail = !$success;
|
||||
}
|
||||
return HttpResponse::found('login', ['fail' => $fail]);
|
||||
}
|
||||
}
|
||||
|
||||
public function register(DI $di): HttpResponse
|
||||
{
|
||||
$fail = false;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$user = $di->getSecurity()->register(User::fromRawPassword($_POST['login'], $_POST['password']));
|
||||
if ($user !== null) {
|
||||
http_response_code(303);
|
||||
header('Location: ' . $di->getRouter()->url(''));
|
||||
exit();
|
||||
}
|
||||
$fail = $user === null;
|
||||
}
|
||||
return HttpResponse::found('register', ['fail' => $fail]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user