From f40be66381f30a003fe1e305951f2a0320e21168 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Thu, 7 Nov 2024 22:56:26 -0500 Subject: [PATCH] Render the page with the status of the user can't log in. --- app/src/Controller/User/LoginUserAction.php | 4 ++-- app/src/Domain/Repository/User/UserRepository.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/Controller/User/LoginUserAction.php b/app/src/Controller/User/LoginUserAction.php index b721200..81b58a6 100644 --- a/app/src/Controller/User/LoginUserAction.php +++ b/app/src/Controller/User/LoginUserAction.php @@ -25,12 +25,12 @@ class LoginUserAction extends Controller $user = $this->userRepository->getFromEmail($credentials['email']); } catch (EntityNotFoundException $e) { $this->session->getFlash()->add('error', "Unable to login user."); - return $this->response->withStatus(400); + return $this->render('user/login.twig')->withStatus(400); } if (!$this->auth->verify($credentials['password'], $user->getPassword())) { $this->session->getFlash()->add('error', "Unable to login."); - return $this->response->withStatus(400); + return $this->render('user/login.twig')->withStatus(400); } // start the session diff --git a/app/src/Domain/Repository/User/UserRepository.php b/app/src/Domain/Repository/User/UserRepository.php index c2aff85..3310c49 100644 --- a/app/src/Domain/Repository/User/UserRepository.php +++ b/app/src/Domain/Repository/User/UserRepository.php @@ -58,7 +58,7 @@ class UserRepository implements UserRepositoryInterface $statement->execute([ ':email' => $email ]); $results = $statement->fetch(\PDO::FETCH_ASSOC); - if (!count($results)) { + if (!is_array($results) || count($results)) { throw new EntityNotFoundException("Unable to find User"); }