From f442185aa5789a3b51c706b2cdfaa50f4fee68f2 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Tue, 28 Feb 2023 21:17:15 +0800 Subject: [PATCH] perf(123): optimize login error --- drivers/123/types.go | 12 ------------ drivers/123/util.go | 4 +--- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/123/types.go b/drivers/123/types.go index 06456dce14b..e1050f6bbdc 100644 --- a/drivers/123/types.go +++ b/drivers/123/types.go @@ -7,18 +7,6 @@ import ( "github.com/alist-org/alist/v3/internal/model" ) -//type BaseResp struct { -// Code interface{} `json:"code"` -// Message string `json:"message"` -//} - -type TokenResp struct { - //BaseResp - Data struct { - Token string `json:"token"` - } `json:"data"` -} - type File struct { FileName string `json:"FileName"` Size int64 `json:"Size"` diff --git a/drivers/123/util.go b/drivers/123/util.go index ace6e5d21b9..57a03a79b42 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -29,9 +29,7 @@ func (d *Pan123) login() error { "password": d.Password, } } - var resp TokenResp res, err := base.RestyClient.R(). - SetResult(&resp). SetBody(body).Post(url) if err != nil { return err @@ -39,7 +37,7 @@ func (d *Pan123) login() error { if utils.Json.Get(res.Body(), "code").ToInt() != 200 { err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString()) } else { - d.AccessToken = resp.Data.Token + d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString() } return err }