/** * 用户登录页 */ public function loginAction() { if ($this->request->isPost() == true) { if ($this->security->checkToken()) { $username = $this->request->getPost('username'); $password = trim($this->request->getPost('password')); $isUser = SunUser::findFirst("username = '******' "); if ($isUser) { if ($this->security->checkHash($password, $isUser->password_hash)) { $this->cookies->set('username', $username, time() + 3600); $this->response->redirect('?_url=/index/index'); } else { //密码错误 $this->response->redirect('?_url=/login/index'); } } else { //不存在该用户 $this->response->redirect('?_url=/login/index'); } } else { $this->response->setStatusCode(404, "Not Found"); } } else { $this->response->setStatusCode(404, "Not Found"); } }
public function indexAction() { echo json_encode(SunUser::findFirst()); echo 'welcome to websocket !'; }
/** * TcpSocket测试样例 */ public function demoAction() { echo json_encode(SunUser::findFirst()); }