From dd0d6603a7fafc7006ecf900aafc0f2fa77edc0f Mon Sep 17 00:00:00 2001 From: eatmoreapple Date: Sun, 27 Nov 2022 23:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- caller.go | 6 ++++++ errors.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/caller.go b/caller.go index 8d01ed7..1714026 100644 --- a/caller.go +++ b/caller.go @@ -4,7 +4,9 @@ import ( "bytes" "encoding/json" "errors" + "fmt" "io" + "net/http" "net/url" "os" ) @@ -86,6 +88,10 @@ func (c *Caller) GetLoginInfo(body []byte) (*LoginInfo, error) { if err != nil { return nil, err } + // 判断是否重定向 + if resp.StatusCode != http.StatusMovedPermanently { + return nil, fmt.Errorf("%w: try to login with Desktop Mode", ErrForbidden) + } defer func() { _ = resp.Body.Close() }() var loginInfo LoginInfo diff --git a/errors.go b/errors.go index 19dfea8..4176404 100644 --- a/errors.go +++ b/errors.go @@ -18,3 +18,6 @@ func IgnoreNetworkError(errHandler func(err error)) func(error) { } } } + +// ErrForbidden 禁止当前账号登录 +var ErrForbidden = errors.New("login forbidden")