Skip to content

Commit

Permalink
perf(123): optimize login error
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 28, 2023
1 parent ca9e739 commit f442185
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
12 changes: 0 additions & 12 deletions drivers/123/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 1 addition & 3 deletions drivers/123/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ 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
}
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
}
Expand Down

0 comments on commit f442185

Please sign in to comment.