mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 21:00:52 +08:00
fix(api): omit auth file entries lacking path unless runtime-only
This commit is contained in:
@@ -292,6 +292,11 @@ func (h *Handler) buildAuthFileEntry(auth *coreauth.Auth) gin.H {
|
|||||||
if auth == nil {
|
if auth == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
runtimeOnly := isRuntimeOnlyAuth(auth)
|
||||||
|
path := strings.TrimSpace(authAttribute(auth, "path"))
|
||||||
|
if path == "" && !runtimeOnly {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
name := strings.TrimSpace(auth.FileName)
|
name := strings.TrimSpace(auth.FileName)
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = auth.ID
|
name = auth.ID
|
||||||
@@ -306,7 +311,7 @@ func (h *Handler) buildAuthFileEntry(auth *coreauth.Auth) gin.H {
|
|||||||
"status_message": auth.StatusMessage,
|
"status_message": auth.StatusMessage,
|
||||||
"disabled": auth.Disabled,
|
"disabled": auth.Disabled,
|
||||||
"unavailable": auth.Unavailable,
|
"unavailable": auth.Unavailable,
|
||||||
"runtime_only": isRuntimeOnlyAuth(auth),
|
"runtime_only": runtimeOnly,
|
||||||
"source": "memory",
|
"source": "memory",
|
||||||
"size": int64(0),
|
"size": int64(0),
|
||||||
}
|
}
|
||||||
@@ -331,7 +336,7 @@ func (h *Handler) buildAuthFileEntry(auth *coreauth.Auth) gin.H {
|
|||||||
if !auth.LastRefreshedAt.IsZero() {
|
if !auth.LastRefreshedAt.IsZero() {
|
||||||
entry["last_refresh"] = auth.LastRefreshedAt
|
entry["last_refresh"] = auth.LastRefreshedAt
|
||||||
}
|
}
|
||||||
if path := strings.TrimSpace(authAttribute(auth, "path")); path != "" {
|
if path != "" {
|
||||||
entry["path"] = path
|
entry["path"] = path
|
||||||
entry["source"] = "file"
|
entry["source"] = "file"
|
||||||
if info, err := os.Stat(path); err == nil {
|
if info, err := os.Stat(path); err == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user