Example #1
0
 public function loginAction()
 {
     $response = array("status" => 0, "message" => "Thao tác không thành công");
     if (!empty($this->user)) {
         $response["status"] = 1;
     } else {
         if ($this->request->isPost()) {
             $username = $this->request->getPost("username", null, false);
             $password = $this->request->getPost("password", null, false);
             $response["message"] = "username hoặc mật khẩu không đúng";
             if (!empty($username) && !empty($password)) {
                 $user_obj = new \HaiQuan\Frontend\Models\Character();
                 $user = $user_obj->getUserByUsernameAndPassword($username, $password);
                 if (!empty($user)) {
                     $response["status"] = 1;
                     $this->loginSuccess($user->toArray());
                 }
             }
         }
     }
     echo json_encode($response);
     exit;
 }