return $response->withHeader('Location', $RouteHelper->getPathFor('auth/users/edit') . '/' . $post['id']);
                }
            } else {
                // On a effectué toutes les vérifications
                if (empty($post['password'])) {
                    unset($post['password']);
                } else {
                    $post['password'] = password_hash($post['password'], PASSWORD_BCRYPT);
                }
                var_dump($post);
                $usrId = $post['id'];
                $rolesSlug = array_keys($post['roles']);
                unset($post['id'], $post['password_confirm'], $post['csrf_name'], $post['csrf_value']);
                if (empty($usrId)) {
                    $usrId = \CoreHelpers\User::insert($post);
                    $msg = "Ajout d'un utilisateur #" . $usrId . " : " . $post['email'] . ' - ' . json_encode($rolesSlug);
                    $this->logger->addInfo($msg);
                    $this->flash->addMessage('success', $msg);
                    echo $msg;
                } else {
                    $msg = "MAJ utilisateur #" . $usrId . " : " . $post['email'] . ' - ' . json_encode($rolesSlug);
                    \CoreHelpers\User::update($usrId, $post, $curUser);
                    $this->logger->addInfo($msg);
                    $this->flash->addMessage('success', $msg);
                    echo $msg;
                }
            }
            return $response->withHeader('Location', $this->router->pathFor('auth/users/list'));
        })->setName('auth/users/commit');
    });
})->add($container->get('csrf'));
 function loginUsingCas($ticket, $service)
 {
     $CAS = new \CoreHelpers\Cas($this->casUrl);
     try {
         $userEmail = $CAS->authenticate($ticket, $service);
     } catch (\Exception $e) {
         $this->flash->addMessage('warning', $e->getMessage());
         return false;
     }
     $user = !empty($userEmail) ? User::getUser($this, $userEmail, null, true) : null;
     if (!empty($user)) {
         if ($user['online'] == 1) {
             // si l'utilisateur est actif dans la BDD
             $_SESSION['Auth'] = array();
             $_SESSION['Auth'] = $user;
             $_SESSION['Auth']['loggedUsingCas'] = true;
             return true;
         } else {
             $this->flash->addMessage('warning', '<strong>Votre compte n\'est pas actif !</strong><br/>Veuillez attendre que les administrateurs activent votre compte ou contactez nous !');
         }
     } else {
         if ($userEmail == 'AuthenticationFailure' || $userEmail == "Cas return is weird" || $userEmail == "Return cannot be parsed") {
             $this->flash->addMessage('danger', $userEmail);
             return false;
         } else {
             if (!empty($userEmail)) {
                 $this->flash->addMessage('warning', "Vous n'avez pas les droits d'accéder au site.<br>Faites la demande aux responsables au besoin.");
             }
         }
     }
     return false;
 }