fix(drivers/cloudreve_v4): remove token check for share (#2274)

Fixed the issue of token verification for shared links.
This commit is contained in:
MadDogOwner
2026-04-04 18:43:08 +08:00
committed by GitHub
parent 12c9bdbd56
commit e11b8a82e7
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -46,6 +46,9 @@ func (d *CloudreveV4) Init(ctx context.Context) error {
if d.ref != nil {
return nil
}
if d.isShare() {
return nil
}
if d.canLogin() {
return d.login()
}
+8
View File
@@ -33,6 +33,7 @@ const (
CodeLoginRequired = http.StatusUnauthorized
CodePathNotExist = 40016 // Path not exist
CodeCredentialInvalid = 40020 // Failed to issue token
// IncorrectSharePassword = 40069 // Incorrect share password
)
var (
@@ -277,9 +278,16 @@ func (d *CloudreveV4) parseJWT(token string, jwt any) error {
return nil
}
func (d *CloudreveV4) isShare() bool {
return strings.HasSuffix(d.GetRootPath(), "@share")
}
// check if token is expired
// https://github.com/cloudreve/frontend/blob/ddfacc1c31c49be03beb71de4cc114c8811038d6/src/session/index.ts#L177-L200
func (d *CloudreveV4) isTokenExpired() bool {
if d.isShare() {
return false
}
if d.RefreshToken == "" {
// login again if username and password is set
if d.canLogin() {