diff --git a/src/Controller/AddressBookAdminController.php b/src/Controller/AddressBookAdminController.php index b773e3c..d8014c9 100644 --- a/src/Controller/AddressBookAdminController.php +++ b/src/Controller/AddressBookAdminController.php @@ -104,7 +104,11 @@ class AddressBookAdminController { $this->adminCheck(); - // TODO currently breaks on inserting a duplicate nick + $nick = $_POST['nick']; + + if ($this->userRepository->findByNick(nick: $nick)) { + die("User: $nick already exists"); + } if (!empty($_POST)) { $isAdmin = empty($_POST['is_admin']) ? 0 : 1; $user = new User(nick: $_POST['nick'], newPassword: $_POST['new_password'], first: $_POST['first'], last: $_POST['last'], isAdmin: $isAdmin); @@ -147,8 +151,10 @@ class AddressBookAdminController die("Error deleting user"); } } else { - // TODO use 404 - die("Nick: $nick not found"); + $this->template->render(templateName: 'status/404.html.php', vars: [ + 'user' => $this->user, + 'router' => $this->router + ]); } }