public function login($uid = null) { if (null !== $uid) { $this->user->login(models\User::get($uid)); } if ($this->user->isLoggedIn()) { $this->_redirect('/blog'); } if ($this->POST) { $post = options($_POST); $get = options($_GET); try { // get user object $user = models\User::withCredentials(array('username' => (string) $post->username, 'password' => (string) $post->password)); // log user in(to SessionUser) $this->user->login($user); // debug direct logged in status Session::message('<pre>' . var_export($this->user->isLoggedIn(), 1) . '</pre>'); // message OK Session::success('Alright, alright, alright, you\'re logged in...'); // back to blog return $this->_redirect($post->get('goto', $get->get('goto', 'blog'))); } catch (\Exception $ex) { } // message FAIL Session::error('Sorry, buddy, that\'s not your username!'); } $messages = Session::messages(); return get_defined_vars(); }