private function validateUsername()
 {
     $username = $this->getElementValue('username');
     if (empty($username)) {
         $this->getElement('username')->setValidationError('You must enter a username.');
         return;
     }
     try {
         $this->user = User::getUser($this->getElementValue('username'));
     } catch (\libAllure\UserNotFoundException $e) {
         $this->setElementError('username', 'User not found');
         return;
     }
     $sql = 'SELECT bi.id FROM basket_items bi WHERE bi.user = :user AND bi.event = :event ';
     $stmt = DatabaseFactory::getInstance()->prepare($sql);
     $stmt->bindValue(':user', $this->user->getId());
     $stmt->bindValue(':event', $this->getElementValue('event'));
     $stmt->execute();
     if ($stmt->numRows() != 0) {
         $this->setElementError('username', 'That user already has a ticket in your basket!');
         return;
     }
     $sql = 'SELECT status FROM signups WHERE user = :user AND event = :event AND status != "SIGNEDUP" ';
     $stmt = DatabaseFactory::getInstance()->prepare($sql);
     $stmt->bindValue(':user', $this->user->getId());
     $stmt->bindValue(':event', $this->getElementValue('event'));
     $stmt->execute();
     if ($stmt->numRows() != 0) {
         $user = $stmt->fetchRow();
         $this->setElementError('username', 'This user is already signed up, with status ' . $user['status']);
         return;
     }
 }
 public function validateExtended()
 {
     try {
         $this->userId = User::getUser($this->getElementValue('username'))->getId();
     } catch (Exception $e) {
         $this->getElement('username')->setValidationError($e->getMessage());
     }
 }
 public function validateExtended()
 {
     try {
         $this->user = User::getUser($this->getElementValue('username'));
     } catch (\libAllure\UserNotFoundException $e) {
         $this->setElementError('username', 'User not found!');
         return false;
     }
     return true;
 }
 public function validateExtended()
 {
     try {
         $user = User::getUser($this->getElementValue('username'));
     } catch (\libAllure\UserNotFoundException $e) {
         $this->getElement('username')->setValidationError('Username not found');
         return;
     }
     $this->validateSiteQuiesse($user);
     $this->validateUserBan($user);
 }
 private function validateUsername()
 {
     if (!is_numeric($this->getElementValue('assignedTo'))) {
         try {
             $user = User::getUser($this->getElementValue('assignedTo'));
             $this->getElement('assignedTo')->setValue($user->getId());
         } catch (\libAllure\UserNotFoundException $e) {
             $this->setElementError('assignedTo', 'Username not found.');
         }
     }
 }
 public function validateExtended()
 {
     if (empty($_SESSION['userHidden'])) {
         try {
             $this->user = User::getUser($this->getElementValue('username'));
             if ($this->user->getData('group') == 1) {
                 $this->setElementError('username', 'You cannot SUDO into an admin account.');
             }
         } catch (\libAllure\UserNotFoundException $e) {
             $this->setElementError('username', 'Username not found');
         }
     }
 }
{
    $sql = 'SELECT a.id FROM authenticated_machines a WHERE a.user = :user AND a.event = :event';
    $stmt = DatabaseFactory::getInstance()->prepare($sql);
    $stmt->bindValue(':user', $user);
    $stmt->bindValue(':event', $event);
    $stmt->execute();
    $authenticatedMachines = $stmt->fetchAll();
    return $authenticatedMachines;
}
$sanitizer = Sanitizer::getInstance();
$username = $sanitizer->filterString('username');
$password = $sanitizer->filterString('password');
$isStaff = $sanitizer->filterString('fullrequest');
try {
    Session::checkCredentials($username, $password);
    $user = User::getUser($username);
} catch (\libAllure\UserNotFoundException $e) {
    apiReturn('reject-authentication', 'User not found');
} catch (\libAllure\IncorrectPasswordException $e) {
    apiReturn('reject-authentication', 'Password is incorrect');
}
$event = getEvent();
$signupStatus = getSignupStatus($user->getId(), $event['id']);
switch ($signupStatus) {
    case 'PAID':
        $authenticatedMachines = getAuthenticatedMachines($user->getId(), $event['id']);
        $sql = 'SELECT s.numberMachinesAllowed FROM signups s WHERE s.user = :user AND s.event = :event';
        $stmt = DatabaseFactory::getInstance()->prepare($sql);
        $stmt->bindValue(':user', $user->getId());
        $stmt->bindValue(':event', $event['id']);
        $stmt->execute();