/** * @brief 执行登录逻辑 * * @return */ public function actionLogin() { // 如果用户已经登录 if ($this->isLogin()) { return $this->showJSON(true); } $form = $this->form('post'); $username = trim($form['username']); $password = $form['password']; if (!$username || !$password) { return $this->showJSON('请填写用户名和密码'); } // 验证用户一卡通和密码是否匹配 if (!$this->verify($username, $password)) { return $this->showJSON('卡号密码不匹配'); } // 以一卡通号获取gapper用户信息 try { $info = self::getRPC()->gapper->user->getUserByIdentity(self::$identitySource, $username); } catch (\Exception $e) { } if ($info['id']) { // 用户已经存在,正常登录 $result = \Gini\Gapper\Client::loginByUserName($info['username']); if ($result) { return $this->showJSON(true); } return $this->showJSON(T('Login failed! Please try again.')); } }