Skip to content

Commit

Permalink
optimize: ErrForbidden 提供具体的错误信息 (#485)
Browse files Browse the repository at this point in the history
Signed-off-by: K8sCat <[email protected]>
  • Loading branch information
k8scat authored Apr 30, 2024
1 parent edc6d33 commit 5254230
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ func (c *Caller) GetLoginInfo(ctx context.Context, path *url.URL) (*LoginInfo, e
// 微信 v2 版本修复了301 response missing Location header 的问题
defer func() { _ = resp.Body.Close() }()

// 这里部分账号可能会被误判, 但是我又没有号测试。如果你遇到了这个问题,可以帮忙解决一下。😊
if _, exists := CookieGroup(resp.Cookies()).GetByName("wxuin"); !exists {
err = ErrForbidden
if c.Client.mode != desktop {
err = fmt.Errorf("%w: try to login with desktop mode", err)
}
return nil, err
}

bs, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
Expand All @@ -99,8 +90,8 @@ func (c *Caller) GetLoginInfo(ctx context.Context, path *url.URL) (*LoginInfo, e
if err = xml.NewDecoder(bytes.NewBuffer(bs)).Decode(&loginInfo); err != nil {
return nil, err
}
if !loginInfo.Ok() {
return nil, loginInfo.Err()
if err = loginInfo.Err(); err != nil {
return nil, err
}
// set domain
c.Client.Domain = WechatDomain(path.Host)
Expand Down

0 comments on commit 5254230

Please sign in to comment.