public function __construct() { $this->data['title'] = 'Login - NCube School'; $this->data['loginAction'] = '/login'; $this->data['registerAction'] = '/register'; $this->data['token'] = Token::generate(); $errors = Session::errors('errors'); if (gettype($errors) === 'string') { $errors = array($errors); } $this->data['errors'] = $errors; }
public function _index() { $post = Input::post(); if (empty($post)) { header('Location: /'); exit; } $validation = Validate::login($post); $token = Token::check($post['token']); $errors = NULL; if ($validation === TRUE && $token === TRUE) { if (!User::login($post['username'], $post['password'])) { $errors = 'Username or Password is Incorrect'; } } else { $errors = $validation; if (!$token) { $errors = 'Security Token Missing'; } } if (!empty($errors)) { Session::errors($errors, '/'); } }