mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 22:42:15 +08:00
fix login refresh token issue
This commit is contained in:
parent
443eac7589
commit
f531c7bc70
@ -304,7 +304,8 @@ func TryLogin() *config.PanUser {
|
||||
config.Config.DeviceId, config.Config.DeviceName,
|
||||
config.Config.ClientId, config.Config.ClientSecret)
|
||||
if cloudUser == nil {
|
||||
fmt.Println("尝试登录失败: ", err)
|
||||
logger.Verboseln("尝试登录失败: ", err)
|
||||
fmt.Println("尝试登录失败,请使用 login 命令进行重新登录")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,3 @@ func (p *PanClient) WebapiPanClient() *aliyunpan_web.WebPanClient {
|
||||
func (p *PanClient) OpenapiPanClient() *aliyunpan_open.OpenPanClient {
|
||||
return p.openapiPanClient
|
||||
}
|
||||
|
||||
func (p *PanClient) UpdateClient(openClient *aliyunpan_open.OpenPanClient, webClient *aliyunpan_web.WebPanClient) {
|
||||
p.webapiPanClient = webClient
|
||||
p.openapiPanClient = openClient
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ func (c *PanConfig) ActiveUser() *PanUser {
|
||||
return u
|
||||
}
|
||||
}
|
||||
return &PanUser{}
|
||||
return nil
|
||||
}
|
||||
return c.activeUser
|
||||
}
|
||||
@ -455,7 +455,7 @@ func (c *PanConfig) SetActiveUser(user *PanUser) *PanUser {
|
||||
u.WebapiToken = user.WebapiToken
|
||||
u.OpenapiToken = user.OpenapiToken
|
||||
u.TicketId = user.TicketId
|
||||
u.PanClient().UpdateClient(user.PanClient().OpenapiPanClient(), user.PanClient().WebapiPanClient())
|
||||
u.UpdateClient(user.PanClient().OpenapiPanClient(), user.PanClient().WebapiPanClient())
|
||||
needToInsert = false
|
||||
break
|
||||
}
|
||||
|
@ -280,6 +280,18 @@ func (pu *PanUser) PanClient() *PanClient {
|
||||
return pu.panClient
|
||||
}
|
||||
|
||||
func (pu *PanUser) UpdateClient(openClient *aliyunpan_open.OpenPanClient, webClient *aliyunpan_web.WebPanClient) {
|
||||
if pu.panClient == nil {
|
||||
pu.panClient = &PanClient{
|
||||
webapiPanClient: webClient,
|
||||
openapiPanClient: openClient,
|
||||
}
|
||||
} else {
|
||||
pu.panClient.webapiPanClient = webClient
|
||||
pu.panClient.openapiPanClient = openClient
|
||||
}
|
||||
}
|
||||
|
||||
// PathJoin 合并工作目录和相对路径p, 若p为绝对路径则忽略
|
||||
func (pu *PanUser) PathJoin(driveId, p string) string {
|
||||
if path.IsAbs(p) {
|
||||
|
8
main.go
8
main.go
@ -102,7 +102,13 @@ func main() {
|
||||
// Token刷新进程,不管是CLI命令行模式,还是直接命令模式,本刷新任务都会执行
|
||||
time.Sleep(time.Duration(1) * time.Minute)
|
||||
//time.Sleep(time.Duration(5) * time.Second)
|
||||
checkLoginExpiredAndRelogin()
|
||||
for _, u := range config.Config.UserList {
|
||||
if u.UserId == config.Config.ActiveUID {
|
||||
if u.PanClient() != nil {
|
||||
checkLoginExpiredAndRelogin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user