Merge branch 'main' of https://codefirst.iut.uca.fr/git/clement.freville2/silex
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]);
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ class UserController
|
||||
} else {
|
||||
$nbCommentsByUser = 0;
|
||||
}
|
||||
return new HttpResponse(200, 'home', ['news' => $news, 'page' => $page, 'nbPages' => $nbPages, 'router' => $di->getRouter(), 'nbComments' => $nbComments, 'nbCommentsByUser' => $nbCommentsByUser]);
|
||||
return new HttpResponse(200, 'home', ['news' => $news, 'page' => $page, 'nbPages' => $nbPages, 'nbComments' => $nbComments, 'nbCommentsByUser' => $nbCommentsByUser]);
|
||||
}
|
||||
|
||||
public function viewPost(DI $di, array $params): HttpResponse
|
||||
|
Reference in New Issue
Block a user