protected function login() { $uid = null; $login_pass = Filter::dbSafe('login_pass', $_POST); $login_pseudo = Filter::dbSafe('login_pseudo', $_POST); $login_mail = Filter::dbSafe('login_mail', $_POST); $login_uid = Filter::dbSafe('uid', $_COOKIE); $login_cookie_token = Filter::dbSafe('token', $_COOKIE); $wantAcookie = Filter::dbSafe('wantAcookie', $_REQUEST); $next = Filter::dbSafe('next', $_POST); $login_mixed = filter::dbSafe('login_mixed', $_POST); if ($login_mixed) { $login_pseudo = $login_mixed; $login_mail = $login_mixed; } $auth = $this->auth(); if (!$auth->isAuth()) { $try = 0; // on cherche uid if (!$uid && $login_pass && $login_pseudo) { $try = 1; $Login = new Login_Pseudo($this); $uid = $Login->getUid($login_pseudo); } if (!$uid && $login_pass && $login_mail) { $try = 1; $Login = new Login_Mail($this); $uid = $Login->getUid($login_mail); } if ($uid && $login_pass) { $try = 1; $login = new Login_Password($this); if ($login->check($uid, $login_pass, 1)) { $auth->check($uid); } } elseif ($login_uid && $login_cookie_token) { $try = 1; $Login = new Login_Password($this); if ($Login->checkCookieToken($login_uid, $login_cookie_token)) { $auth->check($login_uid); } } if ($auth->isAuth()) { if ($wantAcookie) { $Login = new Login_Password($this); $login->sendCookieToken($auth->uid()); } $this->event()->trigger('login_success.core', $auth->uid()); } elseif ($try) { $this->event()->trigger('login_fail.core'); } } else { if (isset($_GET['logout']) || Filter::id('a', $_GET) == 'logout' || Filter::id('action', $_GET) == 'logout') { $uid = $auth->uid(); $auth->logout(); $this->event()->trigger('logout.core', $uid); } } if ($auth->isAuth()) { $this->event()->trigger('logged_in.core', $this->auth()->uid()); } }