mirror of https://github.com/Xhofe/alist
parent
42865486f1
commit
c601bb794b
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
||||||
|
@ -13,14 +14,24 @@ import (
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
|
|
||||||
func (d *Pan123) login() error {
|
func (d *Pan123) login() error {
|
||||||
|
var body base.Json
|
||||||
url := "https://www.123pan.com/api/user/sign_in"
|
url := "https://www.123pan.com/api/user/sign_in"
|
||||||
|
if utils.IsEmailFormat(d.Username) {
|
||||||
|
body = base.Json{
|
||||||
|
"mail": d.Username,
|
||||||
|
"password": d.Password,
|
||||||
|
"type": 2,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
body = base.Json{
|
||||||
|
"passport": d.Username,
|
||||||
|
"password": d.Password,
|
||||||
|
}
|
||||||
|
}
|
||||||
var resp TokenResp
|
var resp TokenResp
|
||||||
_, err := base.RestyClient.R().
|
_, err := base.RestyClient.R().
|
||||||
SetResult(&resp).
|
SetResult(&resp).
|
||||||
SetBody(base.Json{
|
SetBody(body).Post(url)
|
||||||
"passport": d.Username,
|
|
||||||
"password": d.Password,
|
|
||||||
}).Post(url)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "regexp"
|
||||||
|
|
||||||
|
func IsEmailFormat(email string) bool {
|
||||||
|
pattern := `^[0-9a-z][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}[0-9a-z]\.){1,4}[a-z]{2,4}$`
|
||||||
|
reg := regexp.MustCompile(pattern)
|
||||||
|
return reg.MatchString(email)
|
||||||
|
}
|
Loading…
Reference in New Issue