From 1f8c2ba8c5cbcca6fc0521e3cb01ecdfdf3f88b7 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sun, 21 Aug 2022 22:18:50 +0800 Subject: [PATCH] fix bug --- internal/api/client_init/init_config.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/api/client_init/init_config.go b/internal/api/client_init/init_config.go index ec9120601..f36a22065 100644 --- a/internal/api/client_init/init_config.go +++ b/internal/api/client_init/init_config.go @@ -4,6 +4,7 @@ import ( api "Open_IM/pkg/base_info" imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/log" + "Open_IM/pkg/common/token_verify" "Open_IM/pkg/utils" "net/http" @@ -19,6 +20,13 @@ func SetClientInitConfig(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) + err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID) + if err != nil { + errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) + return + } m := make(map[string]interface{}) if req.DiscoverPageURL != nil { m["discover_page_url"] = *req.DiscoverPageURL @@ -28,6 +36,7 @@ func SetClientInitConfig(c *gin.Context) { if err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) + return } } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp) @@ -43,6 +52,13 @@ func GetClientInitConfig(c *gin.Context) { return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) + err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID) + if err != nil { + errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token") + log.NewError(req.OperationID, errMsg, errMsg) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) + return + } config, err := imdb.GetClientInitConfig() if err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())