diff --git a/front/views/Editor.tsx b/front/views/Editor.tsx index 2ee71d1..598f94a 100644 --- a/front/views/Editor.tsx +++ b/front/views/Editor.tsx @@ -146,9 +146,7 @@ function EditorView({ const [content, setContent, saveState] = useContentState( initialContent, isInGuestMode ? SaveStates.Guest : SaveStates.Ok, - useMemo(() => debounceAsync(onContentChange), - [onContentChange], - ), + useMemo(() => debounceAsync(onContentChange), [onContentChange]), ) const [allies, setAllies] = useState(() => diff --git a/public/api/index.php b/public/api/index.php index 4c5eb50..9648ff5 100644 --- a/public/api/index.php +++ b/public/api/index.php @@ -24,7 +24,6 @@ use IQBall\Core\Model\TeamModel; use IQBall\Core\Http\HttpResponse; use IQBall\Core\Http\HttpCodes; - $basePath = get_base_path() . "/api"; function getTacticController(): APITacticController { @@ -58,7 +57,7 @@ function getRoutes(): AltoRouter { $router->setBasePath($basePath); $router->map("OPTIONS", "*", Action::noAuth(fn() => HttpResponse::fromCode(HttpCodes::OK))); - + $router->map("POST", "/auth", Action::noAuth(fn() => getAuthController()->authorize())); $router->map("POST", "/tactic/[i:id]/edit/name", Action::auth(fn(int $id, Account $acc) => getTacticController()->updateName($id, $acc))); $router->map("POST", "/tactic/[i:id]/save", Action::auth(fn(int $id, Account $acc) => getTacticController()->saveContent($id, $acc))); @@ -74,8 +73,6 @@ function getRoutes(): AltoRouter { $router->map("POST", "/admin/delete-teams", Action::noAuth(fn() => getAPITeamController()->deleteTeamSelected())); $router->map("POST", "/admin/team/[i:id]/update", Action::noAuth(fn(int $id) => getAPITeamController()->updateTeam($id))); - - return $router; } diff --git a/src/App/Controller/AuthController.php b/src/App/Controller/AuthController.php index efb8862..27b268a 100644 --- a/src/App/Controller/AuthController.php +++ b/src/App/Controller/AuthController.php @@ -27,13 +27,13 @@ class AuthController { /** * registers given account - * @param mixed[] $request + * @param mixed[] $requestData * @param MutableSessionHandle $session * @return HttpResponse */ - public function register(array $request, MutableSessionHandle $session): HttpResponse { + public function register(array $requestData, MutableSessionHandle $session): HttpResponse { $fails = []; - $request = HttpRequest::from($request, $fails, [ + $request = HttpRequest::from($requestData, $fails, [ "username" => [DefaultValidators::name(), DefaultValidators::lenBetween(2, 32)], "password" => [DefaultValidators::password()], "confirmpassword" => [DefaultValidators::password()], @@ -41,9 +41,7 @@ class AuthController { ]); if (!empty($fails)) { - if (!(in_array($request['username'], $fails)) or !(in_array($request['email'], $fails))) { - return ViewHttpResponse::twig("display_register.html.twig", ['fails' => $fails,'username' => $request['username'],'email' => $request['email']]); - } + return ViewHttpResponse::twig("display_register.html.twig", ['fails' => $fails, 'username' => $requestData['username'], 'email' => $requestData['email'], 'password' => $requestData['password'], 'confirmpassword' => $requestData['confirmpassword'], 'accept' => true]); } if ($request["password"] != $request['confirmpassword']) { @@ -57,7 +55,7 @@ class AuthController { } if (!empty($fails)) { - return ViewHttpResponse::twig("display_register.html.twig", ['fails' => $fails]); + return ViewHttpResponse::twig("display_register.html.twig", ['fails' => $fails, 'password' => $requestData['password'], 'confirmpassword' => $requestData['confirmpassword'], 'accept' => true]); } $session->setAccount($account); @@ -84,7 +82,7 @@ class AuthController { $fails = []; $account = $this->model->login($request['email'], $request['password'], $fails); if (!empty($fails)) { - return ViewHttpResponse::twig("display_login.html.twig", ['fails' => $fails]); + return ViewHttpResponse::twig("display_login.html.twig", ['fails' => $fails, 'password' => $request['password'], 'email' => $request['email']]); } $session->setAccount($account); diff --git a/src/App/Views/display_login.html.twig b/src/App/Views/display_login.html.twig index c609537..6e2d063 100644 --- a/src/App/Views/display_login.html.twig +++ b/src/App/Views/display_login.html.twig @@ -93,14 +93,15 @@ {% endfor %} - + - + Vous n'avez pas de compte ?

+ diff --git a/src/App/Views/display_register.html.twig b/src/App/Views/display_register.html.twig index 7b883a5..1f5a9c9 100644 --- a/src/App/Views/display_register.html.twig +++ b/src/App/Views/display_register.html.twig @@ -101,13 +101,13 @@ - + - +


Vous avez déjà un compte ?