From 5cbea2cab5c2eeaab95951bdf7d96f053d314e99 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 9 Aug 2022 13:52:20 +0800 Subject: [PATCH] Set token kicked status first in forceKickOff --- internal/api/user/user.go | 10 +++++----- internal/msg_gateway/gate/relay_rpc_server.go | 4 ++-- internal/rpc/auth/auth.go | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/api/user/user.go b/internal/api/user/user.go index 257c2a7cf..b861e19ee 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -324,9 +324,9 @@ func SetGlobalRecvMessageOpt(c *gin.Context) { func GetSelfUserInfo(c *gin.Context) { params := api.GetSelfUserInfoReq{} if err := c.BindJSON(¶ms); err != nil { - errMsg := "BindJSON failed " + err.Error() - log.NewError("0", "BindJSON failed ", errMsg) - c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) + errMsg := " BindJSON failed " + err.Error() + log.NewError("0", errMsg) + c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg}) return } req := &rpc.GetUserInfoReq{} @@ -338,8 +338,8 @@ func GetSelfUserInfo(c *gin.Context) { ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") - log.NewError(req.OperationID, errMsg) - c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) + log.NewError(params.OperationID, errMsg) + c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg}) return } diff --git a/internal/msg_gateway/gate/relay_rpc_server.go b/internal/msg_gateway/gate/relay_rpc_server.go index cc64285e6..5218fd111 100644 --- a/internal/msg_gateway/gate/relay_rpc_server.go +++ b/internal/msg_gateway/gate/relay_rpc_server.go @@ -291,14 +291,14 @@ func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (by func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOfflineReq) (*pbRelay.KickUserOfflineResp, error) { log.NewInfo(req.OperationID, "KickUserOffline is arriving", req.String()) for _, v := range req.KickUserIDList { + log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID) + SetTokenKicked(v, int(req.PlatformID), req.OperationID) oldConnMap := ws.getUserAllCons(v) if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn] log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v) ws.sendKickMsg(conn, &UserConn{}) conn.Close() } - log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID) - SetTokenKicked(v, int(req.PlatformID), req.OperationID) } return &pbRelay.KickUserOfflineResp{}, nil } diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index ddd18480d..d6ff26faf 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -67,11 +67,11 @@ func (rpc *rpcAuth) ForceLogout(_ context.Context, req *pbAuth.ForceLogoutReq) ( log.NewError(req.OperationID, errMsg) return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil } - if err := token_verify.DeleteToken(req.FromUserID, int(req.Platform)); err != nil { - errMsg := req.OperationID + " DeleteToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform) - log.NewError(req.OperationID, errMsg) - return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil - } + //if err := token_verify.DeleteToken(req.FromUserID, int(req.Platform)); err != nil { + // errMsg := req.OperationID + " DeleteToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform) + // log.NewError(req.OperationID, errMsg) + // return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil + //} if err := rpc.forceKickOff(req.FromUserID, req.Platform, req.OperationID); err != nil { errMsg := req.OperationID + " forceKickOff failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform) log.NewError(req.OperationID, errMsg)