Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
eb5e6214
Unverified
Commit
eb5e6214
authored
Jan 19, 2026
by
Wesley Liddick
Committed by
GitHub
Jan 19, 2026
Browse files
Merge pull request #332 from geminiwen/main
fix: 修复手动刷新令牌后缓存未清除导致403错误的问题
parents
568d6ee1
a54852e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
backend/cmd/server/wire_gen.go
View file @
eb5e6214
...
@@ -120,7 +120,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
...
@@ -120,7 +120,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
concurrencyService
:=
service
.
ProvideConcurrencyService
(
concurrencyCache
,
accountRepository
,
configConfig
)
concurrencyService
:=
service
.
ProvideConcurrencyService
(
concurrencyCache
,
accountRepository
,
configConfig
)
crsSyncService
:=
service
.
NewCRSSyncService
(
accountRepository
,
proxyRepository
,
oAuthService
,
openAIOAuthService
,
geminiOAuthService
,
configConfig
)
crsSyncService
:=
service
.
NewCRSSyncService
(
accountRepository
,
proxyRepository
,
oAuthService
,
openAIOAuthService
,
geminiOAuthService
,
configConfig
)
sessionLimitCache
:=
repository
.
ProvideSessionLimitCache
(
redisClient
,
configConfig
)
sessionLimitCache
:=
repository
.
ProvideSessionLimitCache
(
redisClient
,
configConfig
)
accountHandler
:=
admin
.
NewAccountHandler
(
adminService
,
oAuthService
,
openAIOAuthService
,
geminiOAuthService
,
antigravityOAuthService
,
rateLimitService
,
accountUsageService
,
accountTestService
,
concurrencyService
,
crsSyncService
,
sessionLimitCache
)
accountHandler
:=
admin
.
NewAccountHandler
(
adminService
,
oAuthService
,
openAIOAuthService
,
geminiOAuthService
,
antigravityOAuthService
,
rateLimitService
,
accountUsageService
,
accountTestService
,
concurrencyService
,
crsSyncService
,
sessionLimitCache
,
compositeTokenCacheInvalidator
)
oAuthHandler
:=
admin
.
NewOAuthHandler
(
oAuthService
)
oAuthHandler
:=
admin
.
NewOAuthHandler
(
oAuthService
)
openAIOAuthHandler
:=
admin
.
NewOpenAIOAuthHandler
(
openAIOAuthService
,
adminService
)
openAIOAuthHandler
:=
admin
.
NewOpenAIOAuthHandler
(
openAIOAuthService
,
adminService
)
geminiOAuthHandler
:=
admin
.
NewGeminiOAuthHandler
(
geminiOAuthService
)
geminiOAuthHandler
:=
admin
.
NewGeminiOAuthHandler
(
geminiOAuthService
)
...
...
backend/internal/handler/admin/account_handler.go
View file @
eb5e6214
...
@@ -45,6 +45,7 @@ type AccountHandler struct {
...
@@ -45,6 +45,7 @@ type AccountHandler struct {
concurrencyService
*
service
.
ConcurrencyService
concurrencyService
*
service
.
ConcurrencyService
crsSyncService
*
service
.
CRSSyncService
crsSyncService
*
service
.
CRSSyncService
sessionLimitCache
service
.
SessionLimitCache
sessionLimitCache
service
.
SessionLimitCache
tokenCacheInvalidator
service
.
TokenCacheInvalidator
}
}
// NewAccountHandler creates a new admin account handler
// NewAccountHandler creates a new admin account handler
...
@@ -60,6 +61,7 @@ func NewAccountHandler(
...
@@ -60,6 +61,7 @@ func NewAccountHandler(
concurrencyService
*
service
.
ConcurrencyService
,
concurrencyService
*
service
.
ConcurrencyService
,
crsSyncService
*
service
.
CRSSyncService
,
crsSyncService
*
service
.
CRSSyncService
,
sessionLimitCache
service
.
SessionLimitCache
,
sessionLimitCache
service
.
SessionLimitCache
,
tokenCacheInvalidator
service
.
TokenCacheInvalidator
,
)
*
AccountHandler
{
)
*
AccountHandler
{
return
&
AccountHandler
{
return
&
AccountHandler
{
adminService
:
adminService
,
adminService
:
adminService
,
...
@@ -73,6 +75,7 @@ func NewAccountHandler(
...
@@ -73,6 +75,7 @@ func NewAccountHandler(
concurrencyService
:
concurrencyService
,
concurrencyService
:
concurrencyService
,
crsSyncService
:
crsSyncService
,
crsSyncService
:
crsSyncService
,
sessionLimitCache
:
sessionLimitCache
,
sessionLimitCache
:
sessionLimitCache
,
tokenCacheInvalidator
:
tokenCacheInvalidator
,
}
}
}
}
...
@@ -608,6 +611,14 @@ func (h *AccountHandler) Refresh(c *gin.Context) {
...
@@ -608,6 +611,14 @@ func (h *AccountHandler) Refresh(c *gin.Context) {
return
return
}
}
// 刷新成功后,清除 token 缓存,确保下次请求使用新 token
if
h
.
tokenCacheInvalidator
!=
nil
{
if
invalidateErr
:=
h
.
tokenCacheInvalidator
.
InvalidateToken
(
c
.
Request
.
Context
(),
updatedAccount
);
invalidateErr
!=
nil
{
// 缓存失效失败只记录日志,不影响主流程
_
=
c
.
Error
(
invalidateErr
)
}
}
response
.
Success
(
c
,
dto
.
AccountFromService
(
updatedAccount
))
response
.
Success
(
c
,
dto
.
AccountFromService
(
updatedAccount
))
}
}
...
...
backend/internal/server/api_contract_test.go
View file @
eb5e6214
...
@@ -442,7 +442,7 @@ func newContractDeps(t *testing.T) *contractDeps {
...
@@ -442,7 +442,7 @@ func newContractDeps(t *testing.T) *contractDeps {
apiKeyHandler
:=
handler
.
NewAPIKeyHandler
(
apiKeyService
)
apiKeyHandler
:=
handler
.
NewAPIKeyHandler
(
apiKeyService
)
usageHandler
:=
handler
.
NewUsageHandler
(
usageService
,
apiKeyService
)
usageHandler
:=
handler
.
NewUsageHandler
(
usageService
,
apiKeyService
)
adminSettingHandler
:=
adminhandler
.
NewSettingHandler
(
settingService
,
nil
,
nil
,
nil
)
adminSettingHandler
:=
adminhandler
.
NewSettingHandler
(
settingService
,
nil
,
nil
,
nil
)
adminAccountHandler
:=
adminhandler
.
NewAccountHandler
(
adminService
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
)
adminAccountHandler
:=
adminhandler
.
NewAccountHandler
(
adminService
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
)
jwtAuth
:=
func
(
c
*
gin
.
Context
)
{
jwtAuth
:=
func
(
c
*
gin
.
Context
)
{
c
.
Set
(
string
(
middleware
.
ContextKeyUser
),
middleware
.
AuthSubject
{
c
.
Set
(
string
(
middleware
.
ContextKeyUser
),
middleware
.
AuthSubject
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment