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..c609537 100644 --- a/src/App/Views/display_login.html.twig +++ b/src/App/Views/display_login.html.twig @@ -57,14 +57,13 @@ } {% endfor %} - .inscr{ + .inscr { font-size: small; - text-align: right; } #buttons{ display: flex; - justify-content: space-between; + justify-content: center; padding: 10px 20px; } @@ -90,22 +89,19 @@
{% for name in fails %} - + {% endfor %} -

Vous n'avez pas de compte ?

-
-
- - -
+ Vous n'avez pas de compte ? +

+
+ +
- - \ No newline at end of file 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); }