diff --git a/drivers/pikpak/pikpak.go b/drivers/pikpak/pikpak.go index 6f6d6d53..5b044f39 100644 --- a/drivers/pikpak/pikpak.go +++ b/drivers/pikpak/pikpak.go @@ -35,17 +35,19 @@ func (driver PikPak) Login(account *model.Account) error { }).Post(url) if err != nil { account.Status = err.Error() + _ = model.SaveAccount(account) return err } log.Debug(res.String()) if e.ErrorCode != 0 { account.Status = e.Error - return errors.New(e.Error) + err = errors.New(e.Error) + } else { + data := res.Body() + account.Status = "work" + account.RefreshToken = jsoniter.Get(data, "refresh_token").ToString() + account.AccessToken = jsoniter.Get(data, "access_token").ToString() } - data := res.Body() - account.Status = "work" - account.RefreshToken = jsoniter.Get(data, "refresh_token").ToString() - account.AccessToken = jsoniter.Get(data, "access_token").ToString() _ = model.SaveAccount(account) return nil } @@ -72,6 +74,8 @@ func (driver PikPak) RefreshToken(account *model.Account) error { // refresh_token 失效,重新登陆 return driver.Login(account) } + account.Status = e.Error + _ = model.SaveAccount(account) return errors.New(e.Error) } data := res.Body() diff --git a/drivers/shandian/shandian.go b/drivers/shandian/shandian.go index 986a583d..3f12f390 100644 --- a/drivers/shandian/shandian.go +++ b/drivers/shandian/shandian.go @@ -34,11 +34,14 @@ func (driver Shandian) Login(account *model.Account) error { return err } if resp.Code != 0 { - return errors.New(resp.Msg) + account.Status = resp.Msg + err = errors.New(resp.Msg) + } else { + account.Status = "work" + account.AccessToken = resp.Data.Token } - account.AccessToken = resp.Data.Token _ = model.SaveAccount(account) - return nil + return err } type File struct {