Compare commits

..

2 Commits

Author SHA1 Message Date
tracer 9867df0a04 sort only if table is actually displayed 2022-10-26 12:33:38 +02:00
tracer 0fba7bc0a0 break up if user already exists 2022-10-26 12:32:37 +02:00
2 changed files with 13 additions and 5 deletions

View File

@ -133,6 +133,8 @@ function sortBy(column) {
} }
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
console.log('loaded') const table = document.getElementById('address_table') || false
if (table) {
sortBy('last') sortBy('last')
}
}) })

View File

@ -104,7 +104,11 @@ class AddressBookAdminController
{ {
$this->adminCheck(); $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)) { if (!empty($_POST)) {
$isAdmin = empty($_POST['is_admin']) ? 0 : 1; $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); $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"); die("Error deleting user");
} }
} else { } else {
// TODO use 404 $this->template->render(templateName: 'status/404.html.php', vars: [
die("Nick: $nick not found"); 'user' => $this->user,
'router' => $this->router
]);
} }
} }