/** * @ignore */ public function login() { if (Request::$method !== 'post') { Auth::clear(); $this->viewFile('{core}views/panel/login.php'); return; } // validations Validation::addRule('username')->isRequired()->errorMessage('Username shouldn\'t be blank.'); // Validation::addRule('username')->isEmail()->errorMessage('Please consider your e-mail address once again.'); Validation::addRule('password')->isRequired()->errorMessage('Password shouldn\'t be blank.'); Validation::addRule('password')->lengthMinimum(4)->errorMessage('Password should be longer than 4 characters at least.'); if (!Validation::validate($_POST)) { Session::set('notification', array('error', 'remove-sign', Validation::getErrorMessages(true))); $this->viewFile('{core}views/panel/login.php'); return; } $username = Request::post('username'); $password = Request::post('password'); // user not found if (!Auth::login($username, $password)) { Session::set('notification', array('error', 'remove-sign', 'User not found')); $this->viewFile('{core}views/panel/login.php'); return; } Http::redirect('panel'); }