/** * @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'); }
/** * @ignore */ public static function remove($uAction, $uSlug) { Auth::checkRedirect('editor'); Session::set('notification', array('info', 'ok-sign', 'Category removed.')); Http::redirect('panel/categories'); }
/** * Redirects users to another location if user does not have required roles * * @uses Auth::check($uRequiredRoles) * @param string $uRequiredRoles roles */ public static function checkRedirect($uRequiredRoles = 'user') { self::load(); if (self::check($uRequiredRoles)) { return; } $tLoginUrl = Config::get('auth/loginUrl', null); if ($tLoginUrl !== null) { //! todo: warning messages like insufficent privileges. Http::redirect($tLoginUrl, true); } Framework::end(0); }