diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 0ccb57697..a06dfeeda 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 0ccb576978b852bc5d8b51badc54daace6fe0b4c +Subproject commit a06dfeeda56815ac9a9bb401dd30ab12b374d658 diff --git a/go.mod b/go.mod index 02b9d322c..a1afd34d0 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/lestrrat-go/strftime v1.0.4 // indirect github.com/lib/pq v1.2.0 // indirect - github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 + //github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 // indirect //github.com/livekit/server-sdk-go v0.9.1 github.com/mattn/go-sqlite3 v1.14.6 // indirect github.com/minio/minio-go/v7 v7.0.22 diff --git a/internal/api/friend/friend.go b/internal/api/friend/friend.go index 1c6b0a9b2..054878c0c 100644 --- a/internal/api/friend/friend.go +++ b/internal/api/friend/friend.go @@ -26,7 +26,7 @@ func AddBlack(c *gin.Context) { req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -57,7 +57,7 @@ func ImportFriend(c *gin.Context) { req := &rpc.ImportFriendReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -97,7 +97,7 @@ func AddFriend(c *gin.Context) { utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) req.ReqMsg = params.ReqMsg var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -131,7 +131,7 @@ func AddFriendResponse(c *gin.Context) { req.HandleMsg = params.HandleMsg req.HandleResult = params.Flag var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -164,7 +164,7 @@ func DeleteFriend(c *gin.Context) { req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -196,7 +196,7 @@ func GetBlacklist(c *gin.Context) { req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -235,7 +235,7 @@ func SetFriendRemark(c *gin.Context) { utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) req.Remark = params.Remark var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -267,7 +267,7 @@ func RemoveBlack(c *gin.Context) { req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -298,7 +298,7 @@ func IsFriend(c *gin.Context) { req := &rpc.IsFriendReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -365,7 +365,7 @@ func GetFriendList(c *gin.Context) { req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -399,7 +399,7 @@ func GetFriendApplyList(c *gin.Context) { req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -433,7 +433,7 @@ func GetSelfFriendApplyList(c *gin.Context) { req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}} utils.CopyStructFields(req.CommID, ¶ms) var ok bool - ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID) if !ok { log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index 887a89594..d7f7ecf11 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -30,7 +30,7 @@ func KickGroupMember(c *gin.Context) { req := &rpc.KickGroupMemberReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -72,7 +72,7 @@ func GetGroupMembersInfo(c *gin.Context) { req := &rpc.GetGroupMembersInfoReq{} utils.CopyStructFields(req, params) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) //c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -107,7 +107,7 @@ func GetGroupMemberList(c *gin.Context) { req := &rpc.GetGroupMemberListReq{} utils.CopyStructFields(req, params) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -142,7 +142,7 @@ func GetGroupAllMemberList(c *gin.Context) { req := &rpc.GetGroupAllMemberReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -175,7 +175,7 @@ func GetJoinedGroupList(c *gin.Context) { req := &rpc.GetJoinedGroupListReq{} utils.CopyStructFields(req, params) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -208,7 +208,7 @@ func InviteUserToGroup(c *gin.Context) { req := &rpc.InviteUserToGroupReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -253,7 +253,7 @@ func CreateGroup(c *gin.Context) { req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel}) } var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -356,7 +356,7 @@ func GetGroupsInfo(c *gin.Context) { req := &rpc.GetGroupsInfoReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -389,7 +389,7 @@ func ApplicationGroupResponse(c *gin.Context) { req := &rpc.GroupApplicationResponseReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -421,7 +421,7 @@ func JoinGroup(c *gin.Context) { req := &rpc.JoinGroupReq{} utils.CopyStructFields(req, params) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -452,7 +452,7 @@ func QuitGroup(c *gin.Context) { req := &rpc.QuitGroupReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -484,7 +484,7 @@ func SetGroupInfo(c *gin.Context) { utils.CopyStructFields(req.GroupInfo, ¶ms) req.OperationID = params.OperationID var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -515,7 +515,7 @@ func TransferGroupOwner(c *gin.Context) { req := &rpc.TransferGroupOwnerReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) diff --git a/internal/api/manage/management_user.go b/internal/api/manage/management_user.go index 6ef6f678f..5bcc19be0 100644 --- a/internal/api/manage/management_user.go +++ b/internal/api/manage/management_user.go @@ -31,7 +31,7 @@ func DeleteUser(c *gin.Context) { req := &rpc.DeleteUsersReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -63,7 +63,7 @@ func GetAllUsersUid(c *gin.Context) { req := &rpc.GetAllUserIDReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -95,7 +95,7 @@ func AccountCheck(c *gin.Context) { req := &rpc.AccountCheckReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -127,7 +127,7 @@ func GetUsersOnlineStatus(c *gin.Context) { req := &pbRelay.GetUsersOnlineStatusReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) diff --git a/internal/api/third/minio_storage_credential.go b/internal/api/third/minio_storage_credential.go index f34f64c94..f4862c062 100644 --- a/internal/api/third/minio_storage_credential.go +++ b/internal/api/third/minio_storage_credential.go @@ -16,7 +16,7 @@ import ( func MinioStorageCredential(c *gin.Context) { var ( - req apiStruct.MinioStorageCredentialReq + req apiStruct.MinioStorageCredentialReq resp apiStruct.MiniostorageCredentialResp ) if err := c.BindJSON(&req); err != nil { @@ -24,7 +24,7 @@ func MinioStorageCredential(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -51,5 +51,5 @@ func MinioStorageCredential(c *gin.Context) { resp.AccessKeyID = v.AccessKeyID resp.BucketName = config.Config.Credential.Minio.Bucket resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint - c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data":resp}) + c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp}) } diff --git a/internal/api/third/tencent_cloud_storage_credential.go b/internal/api/third/tencent_cloud_storage_credential.go index d78d03b96..ed293791e 100644 --- a/internal/api/third/tencent_cloud_storage_credential.go +++ b/internal/api/third/tencent_cloud_storage_credential.go @@ -22,7 +22,7 @@ func TencentCloudStorageCredential(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) diff --git a/internal/api/user/user.go b/internal/api/user/user.go index 4fa1c62dd..1756a9f8d 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -26,7 +26,7 @@ func GetUsersInfo(c *gin.Context) { req := &rpc.GetUserInfoReq{} utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -66,7 +66,7 @@ func UpdateUserInfo(c *gin.Context) { req.OperationID = params.OperationID var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) @@ -98,7 +98,7 @@ func GetSelfUserInfo(c *gin.Context) { utils.CopyStructFields(req, ¶ms) var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index 477d43420..afade2f7f 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -131,10 +131,12 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int32, newCo log.NewError("", "conn close err", err.Error(), uid, platformID) } + } else { + log.NewWarn("", "abnormal uid-conn ", uid, platformID, oldConnMap[constant.PlatformIDToName(platformID)]) } } else { - log.NewDebug("no other conn", ws.wsUserToConn) + log.NewDebug("no other conn", ws.wsUserToConn, uid, platformID) } case constant.SingleTerminalLogin: diff --git a/pkg/common/constant/error.go b/pkg/common/constant/error.go index 548720a37..b41474b03 100644 --- a/pkg/common/constant/error.go +++ b/pkg/common/constant/error.go @@ -9,7 +9,7 @@ type ErrInfo struct { } var ( - OK = ErrInfo{0, ""} + OK = ErrInfo{0, ""} ErrServer = ErrInfo{500, "server error"} // ErrMysql = ErrInfo{100, ""} @@ -47,10 +47,11 @@ var ( ErrTokenMalformed = ErrInfo{703, TokenMalformedMsg.Error()} ErrTokenNotValidYet = ErrInfo{704, TokenNotValidYetMsg.Error()} ErrTokenUnknown = ErrInfo{705, TokenUnknownMsg.Error()} + ErrTokenKicked = ErrInfo{706, TokenUserKickedMsg.Error()} - ErrAccess = ErrInfo{ErrCode: 801, ErrMsg: AccessMsg.Error()} - ErrDB = ErrInfo{ErrCode: 802, ErrMsg: DBMsg.Error()} - ErrArgs = ErrInfo{ErrCode: 8003, ErrMsg: ArgsMsg.Error()} + ErrAccess = ErrInfo{ErrCode: 801, ErrMsg: AccessMsg.Error()} + ErrDB = ErrInfo{ErrCode: 802, ErrMsg: DBMsg.Error()} + ErrArgs = ErrInfo{ErrCode: 8003, ErrMsg: ArgsMsg.Error()} ErrCallback = ErrInfo{ErrCode: 809, ErrMsg: CallBackMsg.Error()} ) @@ -61,11 +62,11 @@ var ( TokenNotValidYetMsg = errors.New("token not active yet") TokenMalformedMsg = errors.New("that's not even a token") TokenUnknownMsg = errors.New("couldn't handle this token") - - AccessMsg = errors.New("no permission") - DBMsg = errors.New("db failed") - ArgsMsg = errors.New("args failed") - CallBackMsg = errors.New("callback failed") + TokenUserKickedMsg = errors.New("user has been kicked") + AccessMsg = errors.New("no permission") + DBMsg = errors.New("db failed") + ArgsMsg = errors.New("args failed") + CallBackMsg = errors.New("callback failed") ThirdPartyMsg = errors.New("third party error") ) @@ -90,7 +91,7 @@ const ( IntentionalError = 10007 ) -func (e ErrInfo) Error() string { +func (e *ErrInfo) Error() string { return e.ErrMsg } diff --git a/pkg/common/token_verify/jwt_token.go b/pkg/common/token_verify/jwt_token.go index 50aecc8ae..4ace7048b 100644 --- a/pkg/common/token_verify/jwt_token.go +++ b/pkg/common/token_verify/jwt_token.go @@ -129,9 +129,10 @@ func CheckAccess(OpUserID string, OwnerUserID string) bool { return false } -func GetUserIDFromToken(token string) (bool, string) { +func GetUserIDFromToken(token string, operationID string) (bool, string) { claims, err := ParseToken(token) if err != nil { + log.Error(operationID, "ParseToken failed, ", err.Error(), token) return false, "" } return true, claims.UID @@ -162,7 +163,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) { case constant.InValidToken: return nil, &constant.ErrTokenInvalid case constant.KickedToken: - return nil, &constant.ErrTokenInvalid + return nil, &constant.ErrTokenKicked case constant.ExpiredToken: return nil, &constant.ErrTokenExpired default: