Skip to content

Commit

Permalink
优化更新SSO登录失败验证规则
Browse files Browse the repository at this point in the history
  • Loading branch information
Airmole committed Sep 29, 2024
1 parent bf6e46c commit 44fadcd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/SsoLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down

0 comments on commit 44fadcd

Please sign in to comment.