public static function controleerGebruiker($login, $paswoord)
 {
     $user = UserDAO::getByLogin($login);
     if (isset($user) and $user->getPaswoord() == $paswoord) {
         print "Userservice true <br>";
         // PRINT
         return TRUE;
     } else {
         print "Userservice false <br>";
         // PRINT
         return NULL;
     }
 }
$badInput = false;
foreach ($badAgents as $agent) {
    if (strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== false) {
        $bot = true;
        break;
    }
}
if (isset($_SESSION['cocktailsUser']) && get_class($_SESSION['cocktailsUser']) == 'User') {
    $request->redirect('index');
} elseif (isset($_POST['submit'])) {
    if ($_POST['user'] == '' || $_POST['password'] == '') {
        $badInput = true;
    } elseif (!$bot) {
        //require MODELS_INC.'UserDAO.class.php';
        //require 'passwordHash.inc.php';
        $user = UserDAO::getByLogin($_POST['user']);
        if ($user != NULL) {
            if (empty($user) || !Transitive\Utils\Passwords::validate_password($_POST['password'], $user->getPassword())) {
                $badInput = true;
                sleep(1);
            } else {
                $_SESSION['cocktailsUser'] = $user;
                FavoriteDAO::sync();
                if (!empty($_SESSION['referrer']) && $_SESSION['referrer'] != 'login' && $_SESSION['referrer'] != 'logout') {
                    $request->redirect($_SESSION['referrer']);
                } else {
                    $request->redirect('index');
                }
                exit;
            }
        } else {
<?php

if (!isset($_SESSION['cocktailsUser'])) {
    $request->redirect('signin');
}
require_once MODELS_INC . 'UserDAO.class.php';
use Transitive\Utils\Validation;
$user = UserDAO::getByLogin($_SESSION['cocktailsUser']->getLogin());
$formValidation = null;
if ($_POST) {
    $modified = false;
    Validation::trimForm(array('firstName', 'lastName', 'sex', 'email', 'birthDate', 'address', 'postalCode', 'city', 'phoneNumber'), $_POST);
    Validation::validateForm(array('firstName' => function ($value) {
        return !Validation::contains_numeric($value) ? true : 'Un prénom n\'a pas de chiffres ...';
    }, 'lastName' => function ($value) {
        return !Validation::contains_numeric($value) ? true : 'Un nom n\'a pas de chiffres ...';
    }, 'city' => function ($value) {
        return !Validation::contains_numeric($value) ? true : 'Une ville n\'a pas de chiffres ...';
    }, 'phoneNumber' => function ($value) {
        return !empty($value) && Validation::is_valid_phoneNumber($value) || $value == "" || empty($value) ? true : 'Numéro de téléphone non valide';
    }, 'email' => function ($value) {
        return Validation::is_valid_email($value) || $value == "" || empty($value) ? true : 'Mail non valide';
    }), $_POST);
    if (Validation::isFormValid()) {
        if ($_POST['firstName'] != $user->getFirstName()) {
            $user->setFirstName($_POST['firstName']);
            $modified = true;
        }
        if ($_POST['lastName'] != $user->getLastName()) {
            $user->setLastName($_POST['lastName']);
            $modified = true;
<?php

require_once MODELS_INC . 'UserDAO.class.php';
use Transitive\Utils\Passwords;
use Transitive\Utils\Validation;
if (isset($_SESSION['cocktailsUser'])) {
    $request->redirect('profile');
}
if ($_POST) {
    $modified = false;
    Validation::trimForm(array('firstName', 'lastName', 'sex', 'email', 'birthDate', 'address', 'postalCode', 'city', 'phoneNumber'), $_POST);
    Validation::validateForm(array('login' => function ($value) {
        return !UserDAO::getByLogin($_POST['login']) ? true : 'Un utilisateur possède déjà ce nom';
    }, 'firstName' => function ($value) {
        return !Validation::contains_numeric($value) ? true : 'Un prénom n\'a pas de chiffres ...';
    }, 'lastName' => function ($value) {
        return !Validation::contains_numeric($value) ? true : 'Un nom n\'a pas de chiffres ...';
    }, 'city' => function ($value) {
        return !Validation::contains_numeric($value) ? true : 'Une ville n\'a pas de chiffres ...';
    }, 'phoneNumber' => function ($value) {
        return !empty($value) && Validation::is_valid_phoneNumber($value) || $value == "" || empty($value) ? true : 'Numéro de téléphone non valide';
    }, 'email' => function ($value) {
        return Validation::is_valid_email($value) || $value == "" || empty($value) ? true : 'Mail non valide';
    }), $_POST);
    if (Validation::isFormValid()) {
        $_POST['birthDate'] = $_POST['yBirthDate'] . '-' . $_POST['mBirthDate'] . '-' . $_POST['dBirthDate'];
        $password = Passwords::create_hash($_POST['password']);
        $newUser = new User($_POST['login'], $password, $_POST['firstName'], $_POST['lastName'], $_POST['sex'], $_POST['email'], $_POST['birthDate'], $_POST['address'], $_POST['postalCode'], $_POST['city'], $_POST['phoneNumber']);
        UserDAO::create($newUser);
        $request->redirect('login');
    }