fix: accept numeric login identifiers
This commit is contained in:
@@ -238,15 +238,26 @@ type qrLoginData struct {
|
||||
}
|
||||
|
||||
type longPollData struct {
|
||||
Code int `json:"code"`
|
||||
Desc string `json:"desc"`
|
||||
Location string `json:"location"`
|
||||
Psecurity string `json:"psecurity"`
|
||||
Nonce string `json:"nonce"`
|
||||
Ssecurity string `json:"ssecurity"`
|
||||
PassToken string `json:"passToken"`
|
||||
UserID string `json:"userId"`
|
||||
CUserID string `json:"cUserId"`
|
||||
Code int `json:"code"`
|
||||
Desc string `json:"desc"`
|
||||
Location string `json:"location"`
|
||||
Psecurity string `json:"psecurity"`
|
||||
Nonce stringOrNumber `json:"nonce"`
|
||||
Ssecurity string `json:"ssecurity"`
|
||||
PassToken string `json:"passToken"`
|
||||
UserID stringOrNumber `json:"userId"`
|
||||
CUserID stringOrNumber `json:"cUserId"`
|
||||
}
|
||||
|
||||
type stringOrNumber string
|
||||
|
||||
func (value *stringOrNumber) UnmarshalJSON(payload []byte) error {
|
||||
decoded, err := decodeStringOrNumber(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*value = stringOrNumber(decoded)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *Client) Login(ctx context.Context) (AuthData, error) {
|
||||
@@ -403,11 +414,11 @@ func (client *Client) completeQRLogin(ctx context.Context, loginData qrLoginData
|
||||
candidate.ServiceToken = ""
|
||||
serviceTokenReceived := updateAuthDataFromCookies(&candidate, httpClient, response.Request.URL)
|
||||
candidate.Psecurity = data.Psecurity
|
||||
candidate.Nonce = data.Nonce
|
||||
candidate.Nonce = string(data.Nonce)
|
||||
candidate.Ssecurity = data.Ssecurity
|
||||
candidate.PassToken = data.PassToken
|
||||
candidate.UserID = data.UserID
|
||||
candidate.CUserID = data.CUserID
|
||||
candidate.UserID = string(data.UserID)
|
||||
candidate.CUserID = string(data.CUserID)
|
||||
if !serviceTokenReceived || !candidate.complete() {
|
||||
return AuthData{}, &LoginError{Code: -1, Message: "登录回调认证信息不完整"}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user