Compare commits

...

3 Commits

Author SHA1 Message Date
WangZhonghui
798febe735
Merge 5afa9d1e7947fb79f390d44c25268cb0afa4f5ef into d817cb0ffd4ad9c540a36b358c71c081e800920b 2025-08-05 18:38:06 +08:00
chao
d817cb0ffd
fix: admin token in standalone mode (#3499)
* fix: performance issues with Kafka caused by encapsulating the MQ interface

* fix: admin token in standalone mode
2025-08-01 02:48:25 +00:00
WangZhonghui
5afa9d1e79
fix: get online users
get online users fail
2025-07-18 11:44:19 +08:00
3 changed files with 12 additions and 6 deletions

View File

@ -97,6 +97,11 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, cf
case BestSpeed:
r.Use(gzip.Gzip(gzip.BestSpeed))
}
if config.Standalone() {
r.Use(func(c *gin.Context) {
c.Set(authverify.CtxAdminUserIDsKey, cfg.Share.IMAdminUser.UserIDs)
})
}
r.Use(api.GinLogger(), prommetricsGin(), gin.RecoveryWithWriter(gin.DefaultErrorWriter, mw.GinPanicErr), mw.CorsHandler(),
mw.GinParseOperationID(), GinParseToken(rpcli.NewAuthClient(authConn)), setGinIsAdmin(cfg.Share.IMAdminUser.UserIDs))

View File

@ -89,7 +89,9 @@ func (a *ApiCmd) runE() error {
&a.apiConfig.Notification,
a.apiConfig,
[]string{},
[]string{},
[]string{
a.apiConfig.Discovery.RpcService.MessageGateway,
},
api.Start,
)
}

View File

@ -165,16 +165,15 @@ func (c *tokenCache) DeleteTokenByTokenMap(ctx context.Context, userID string, t
}
func (c *tokenCache) DeleteAndSetTemporary(ctx context.Context, userID string, platformID int, fields []string) error {
key := cachekey.GetTokenKey(userID, platformID)
if err := c.rdb.HDel(ctx, key, fields...).Err(); err != nil {
return errs.Wrap(err)
}
for _, f := range fields {
k := cachekey.GetTemporaryTokenKey(userID, platformID, f)
if err := c.rdb.Set(ctx, k, "", time.Minute*5).Err(); err != nil {
return errs.Wrap(err)
}
}
key := cachekey.GetTokenKey(userID, platformID)
if err := c.rdb.HDel(ctx, key, fields...).Err(); err != nil {
return errs.Wrap(err)
}
return nil
}