break up if user already exists
This commit is contained in:
		@@ -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
 | 
				
			||||||
 | 
					            ]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user