feat(auth): centralize token store management and enhance persistence

- Introduced `RegisterTokenStore` and `GetTokenStore` to centralize token store access.
- Replaced direct file operations with a unified token persistence API.
- Updated all components to use the shared token store for consistent behavior.
- Improved logging for token save operations to include file paths.
This commit is contained in:
Luis Pater
2025-09-25 03:17:50 +08:00
parent 19609db13c
commit 8fc73874de
7 changed files with 107 additions and 24 deletions

View File

@@ -17,6 +17,7 @@ import (
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator"
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
log "github.com/sirupsen/logrus"
"gopkg.in/natefinch/lumberjack.v2"
)
@@ -185,6 +186,9 @@ func main() {
NoBrowser: noBrowser,
}
// Register the shared token store once so all components use the same persistence backend.
sdkAuth.RegisterTokenStore(sdkAuth.NewFileTokenStore())
// Handle different command modes based on the provided flags.
if login {