mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-10-10 04:53:09 +08:00
fix(drivers/cloudreve_v4): remove token check for share (#2274)
Fixed the issue of token verification for shared links.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user