fix(xunlei):missing x-client-id error in some user requests
This commit is contained in:
parent
bf0ee3d315
commit
52dcbfe1a4
@ -105,7 +105,7 @@ func (driver XunLeiCloud) Items() []base.Item {
|
|||||||
Label: "device id",
|
Label: "device id",
|
||||||
Default: utils.GetMD5Encode(uuid.NewString()),
|
Default: utils.GetMD5Encode(uuid.NewString()),
|
||||||
Type: base.TypeString,
|
Type: base.TypeString,
|
||||||
Required: false,
|
Required: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,8 +118,10 @@ func (driver XunLeiCloud) Save(account *model.Account, old *model.Account) error
|
|||||||
client := GetClient(account)
|
client := GetClient(account)
|
||||||
// 指定验证通过的captchaToken
|
// 指定验证通过的captchaToken
|
||||||
if client.captchaToken != "" {
|
if client.captchaToken != "" {
|
||||||
|
client.Lock()
|
||||||
client.captchaToken = account.CaptchaToken
|
client.captchaToken = account.CaptchaToken
|
||||||
account.CaptchaToken = ""
|
account.CaptchaToken = ""
|
||||||
|
client.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.token == "" {
|
if client.token == "" {
|
||||||
|
@ -73,6 +73,8 @@ func (c *Client) requestCaptchaToken(action string, meta map[string]string) erro
|
|||||||
SetBody(¶m).
|
SetBody(¶m).
|
||||||
SetError(&e).
|
SetError(&e).
|
||||||
SetResult(&resp).
|
SetResult(&resp).
|
||||||
|
SetHeader("X-Device-Id", c.deviceID).
|
||||||
|
SetQueryParam("client_id", c.clientID).
|
||||||
Post(XLUSER_API_URL + "/shield/captcha/init")
|
Post(XLUSER_API_URL + "/shield/captcha/init")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -133,6 +135,8 @@ func (c *Client) Login(account *model.Account) (err error) {
|
|||||||
Username: account.Username,
|
Username: account.Username,
|
||||||
Password: account.Password,
|
Password: account.Password,
|
||||||
}).
|
}).
|
||||||
|
SetHeader("X-Device-Id", c.deviceID).
|
||||||
|
SetQueryParam("client_id", c.clientID).
|
||||||
Post(url)
|
Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -184,6 +188,8 @@ func (c *Client) RefreshToken() error {
|
|||||||
"client_id": c.clientID,
|
"client_id": c.clientID,
|
||||||
"client_secret": c.clientSecret,
|
"client_secret": c.clientSecret,
|
||||||
}).
|
}).
|
||||||
|
SetHeader("X-Device-Id", c.deviceID).
|
||||||
|
SetQueryParam("client_id", c.clientID).
|
||||||
Post(XLUSER_API_URL + "/auth/token")
|
Post(XLUSER_API_URL + "/auth/token")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -211,7 +217,8 @@ func (c *Client) Request(method string, url string, callback func(*resty.Request
|
|||||||
"X-Captcha-Token": c.captchaToken,
|
"X-Captcha-Token": c.captchaToken,
|
||||||
"User-Agent": c.userAgent,
|
"User-Agent": c.userAgent,
|
||||||
"client_id": c.clientID,
|
"client_id": c.clientID,
|
||||||
}).SetQueryParam("client_id", c.clientID)
|
}).
|
||||||
|
SetQueryParam("client_id", c.clientID)
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
callback(req)
|
callback(req)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user