修改登录失败处理

This commit is contained in:
eatmoreapple 2022-11-27 23:08:31 +08:00
parent fe2f73b5a2
commit dd0d6603a7
2 changed files with 9 additions and 0 deletions

View File

@ -4,7 +4,9 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io" "io"
"net/http"
"net/url" "net/url"
"os" "os"
) )
@ -86,6 +88,10 @@ func (c *Caller) GetLoginInfo(body []byte) (*LoginInfo, error) {
if err != nil { if err != nil {
return nil, err 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() }() defer func() { _ = resp.Body.Close() }()
var loginInfo LoginInfo var loginInfo LoginInfo

View File

@ -18,3 +18,6 @@ func IgnoreNetworkError(errHandler func(err error)) func(error) {
} }
} }
} }
// ErrForbidden 禁止当前账号登录
var ErrForbidden = errors.New("login forbidden")