From 44fadcdf63c43e7f4538cc24513f084a38f152fa Mon Sep 17 00:00:00 2001 From: Airmole Date: Sun, 29 Sep 2024 19:26:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0SSO?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=B1=E8=B4=A5=E9=AA=8C=E8=AF=81=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SsoLogin.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SsoLogin.php b/src/SsoLogin.php index 742137c..5a440cd 100644 --- a/src/SsoLogin.php +++ b/src/SsoLogin.php @@ -77,9 +77,10 @@ public function login(string $usercode, string $password, string $cookie, string ]; $postString = http_build_query($postData); $result = $this->httpPostLogin($url, $postString, $cookie); - if ($result['code'] !== 200) throw new Exception('登录失败' . json_encode($result)); - $validateResult = $this->validateLoginResult($result); - if ($validateResult !== true) return $validateResult; + if ($result['code'] !== 200) { + $validateResult = $this->validateLoginResult($result); + if ($validateResult !== true) return $validateResult; + } preg_match_all('/Set-Cookie: JSESSIONID=(.*?); Path=\/jsxsd/', $result['data'], $newCookie); if (!isset($newCookie[1]) || !isset($newCookie[1][0])) throw new Exception('登录获取cookie失败' . json_encode($newCookie)); $newCookieValue = $newCookie[1][0]; @@ -96,6 +97,7 @@ public function login(string $usercode, string $password, string $cookie, string */ public function validateLoginResult(array $response) { + if (strpos($response['data'], '该账号非常用账号或用户名密码有误')) return ['code' => 403, 'data' => '用户名或密码错误']; if (strpos($response['data'], '您提供的用户名或者密码有误')) return ['code' => 403, 'data' => '用户名或密码错误']; if (strpos($response['data'], '登录凭证不可用')) return ['code' => 403, 'data' => '登录凭证不可用']; return true;