refactor: simplify ExternalInfoMiddleware and update GetExternalInfo to accept user token secret

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
mlogclub
2026-04-28 10:40:53 +08:00
parent 4ec529e860
commit 2900e0a3d2
2 changed files with 17 additions and 25 deletions
+6 -4
View File
@@ -11,11 +11,13 @@ import (
func ExternalInfoMiddleware(ctx iris.Context) {
channel := services.ChannelService.GetEnabledChannel(ctx)
var userTokenSecret string
if channel != nil {
userTokenSecret = services.ChannelService.GetUserTokenSecret(channel)
if channel == nil {
ctx.StopExecution()
_ = ctx.JSON(web.JsonErrorMsg("接入渠道异常"))
return
}
ext, err := openidentity.GetExternalInfoWithUserTokenSecret(ctx, userTokenSecret)
secret := services.ChannelService.GetUserTokenSecret(channel)
ext, err := openidentity.GetExternalInfo(ctx, secret)
if err != nil {
ctx.StopExecution()
_ = ctx.JSON(web.JsonError(err))