/**
  * Tests if the mail address and the password given by the user exist in the database.
  **/
 public function controlConnection()
 {
     $accountView = new AccountView();
     if (count($_POST) > 0) {
         $accountModel = new AccountModel();
         $_POST['mail'] = htmlspecialchars($_POST['mail']);
         $_POST['pass'] = htmlspecialchars(sha1($_POST['pass']));
         if ($userResult = $accountModel->getUserByPassword($_POST['mail'], $_POST['pass'])) {
             $_SESSION['infoUser'] = $userResult;
             //print_r($userResult);
             if ($_SESSION['infoUser']['user_type'] == 'RF') {
                 $rfResult = $accountModel->getDataTrainingManager('*', $_SESSION['infoUser']['user_id']);
                 $_SESSION['infoRF'] = $rfResult;
             } else {
                 $studentResult = $accountModel->getDataStudent('*', $_SESSION['infoUser']['user_id']);
                 $_SESSION['infoStudent'] = $studentResult;
                 $trainingResult = $accountModel->getTrainingInformationsForUser('*', $_SESSION['infoUser']['user_id']);
                 $_SESSION['infoTraining'] = $trainingResult;
             }
             $accountView->showMessage(null, "ok", "index.php");
         } else {
             $accountView->showMessage("Erreur d'authentification !");
         }
     }
 }