function accueil() { $success = array('success' => '1'); if (isset($_POST)) { if (isset($_POST['username']) && isset($_POST['password'])) { require_once WEBAPPROOT . 'security/AuthentificationManager.php'; $username = $_POST['username']; $password = $_POST['password']; $auth = new AuthentificationManager(); $password_hash = md5($password); $result = $auth->login($username, $password_hash); if ($result == null) { //traiter erreur $success = array('success' => '0'); } else { if ($result->getIs_admin() == '1') { $this->redirect('admin/home'); } else { $success = array('success' => '0'); } } } } require_once WEBAPPROOT . 'security/AuthentificationManager.php'; $auth = new AuthentificationManager(); if ($auth->getUser() != null) { if ($auth->getUser()->getIs_admin() == '1') { $this->redirect('admin/home'); } } $this->set($success); $this->partialView('connecter'); }
function connecter() { if (isset($_POST)) { if (isset($_POST['username']) && isset($_POST['password'])) { require_once WEBAPPROOT . 'security/AuthentificationManager.php'; $username = $_POST['username']; $password = $_POST['password']; $auth = new AuthentificationManager(); $password_hash = md5($password); $result = $auth->login($username, $password_hash); if ($result == null) { //traiter erreur var_dump("Erreur"); } else { $this->redirect('accueil'); } } } $this->render('connecter'); }