From d3a103f95a3da80eb6880c5d1a201d0907d0a3e1 Mon Sep 17 00:00:00 2001 From: samuel Date: Mon, 11 Dec 2023 15:49:07 +0100 Subject: [PATCH] fix bugs and requests of PO : less informations for login --- src/App/Controller/AuthController.php | 8 -------- src/App/Views/display_login.html.twig | 9 ++++----- src/App/Views/display_register.html.twig | 8 ++++---- src/Core/Model/AuthModel.php | 10 ++-------- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/App/Controller/AuthController.php b/src/App/Controller/AuthController.php index dfc5f52..cd89d11 100644 --- a/src/App/Controller/AuthController.php +++ b/src/App/Controller/AuthController.php @@ -64,14 +64,6 @@ class AuthController { */ public function login(array $request, MutableSessionHandle $session): HttpResponse { $fails = []; - $request = HttpRequest::from($request, $fails, [ - "password" => [Validators::lenBetween(6, 256)], - "email" => [Validators::email(), Validators::lenBetween(5, 256)], - ]); - if (!empty($fails)) { - return ViewHttpResponse::twig("display_login.html.twig", ['fails' => $fails]); - } - $account = $this->model->login($request['email'], $request['password'], $fails); if (!empty($fails)) { return ViewHttpResponse::twig("display_login.html.twig", ['fails' => $fails]); diff --git a/src/App/Views/display_login.html.twig b/src/App/Views/display_login.html.twig index a9fe349..8f10529 100644 --- a/src/App/Views/display_login.html.twig +++ b/src/App/Views/display_login.html.twig @@ -64,7 +64,7 @@ #buttons{ display: flex; - justify-content: space-between; + justify-content: center; padding: 10px 20px; } @@ -90,18 +90,17 @@
{% for name in fails %} - + {% endfor %} -

Vous n'avez pas de compte ?

+ 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 bd17ec6..38bdb43 100644 --- a/src/App/Views/display_register.html.twig +++ b/src/App/Views/display_register.html.twig @@ -64,7 +64,7 @@ #buttons{ display: flex; - justify-content: space-between; + justify-content: center; padding: 10px 20px; } @@ -102,11 +102,11 @@ -

Vous avez déja un compte ?

+ Vous avez déjà un compte ? +
- - +
diff --git a/src/Core/Model/AuthModel.php b/src/Core/Model/AuthModel.php index a6ada53..e8710c0 100644 --- a/src/Core/Model/AuthModel.php +++ b/src/Core/Model/AuthModel.php @@ -63,16 +63,10 @@ class AuthModel { */ public function login(string $email, string $password, array &$failures): ?Account { $hash = $this->gateway->getHash($email); - if ($hash == null) { - $failures[] = new FieldValidationFail("email", "l'addresse email n'est pas connue."); + if ($hash == null or (!password_verify($password, $hash))) { + $failures[] = new ValidationFail("email","Adresse email ou mot de passe invalide"); return null; } - - if (!password_verify($password, $hash)) { - $failures[] = new FieldValidationFail("password", "Mot de passe invalide."); - return null; - } - return $this->gateway->getAccountFromMail($email); }