public function handle() { if ($this->request->action_is('login')) { $login = new LoginValidator($this->request); if ($login->successful()) { $this->t->flash('You have been logged in.', 'success'); $login->user->login(); NeechyResponse::redirect($login->user->url()); } else { $this->t->data('validation-errors', $login->errors); $this->t->data('login-name', $this->request->post('login-name')); $content = $this->render_view('login'); } $this->t->data('alert', 'logging in'); } elseif ($this->request->action_is('signup')) { $validator = new SignUpValidator($this->request); if ($validator->is_valid()) { $user = User::register($this->request->post('signup-name'), $this->request->post('signup-email'), $this->request->post('signup-pass')); $page = $this->save_user_page($user); NeechyResponse::redirect($page->url()); } else { $this->t->data('validation-errors', $validator->errors); $this->t->data('signup-name', $this->request->post('signup-name')); $this->t->data('signup-email', $this->request->post('signup-email')); $content = $this->render_view('login'); } } elseif ($this->request->page_is('logout')) { $this->t->flash('You have been logged out.', 'success'); User::logout_current(); $content = $this->render_view('login'); } else { $content = $this->render_view('login'); } return $this->respond($content); }