|
|
@ -134,19 +134,30 @@ func ForceLogout(c *gin.Context) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req := &rpc.ForceLogoutReq{}
|
|
|
|
|
|
|
|
utils.CopyStructFields(req, ¶ms)
|
|
|
|
|
|
|
|
|
|
|
|
var ok bool
|
|
|
|
var ok bool
|
|
|
|
var errInfo string
|
|
|
|
var errInfo string
|
|
|
|
var expireTime int64
|
|
|
|
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
|
|
ok, _, errInfo, expireTime = token_verify.GetUserIDFromTokenExpireTime(c.Request.Header.Get("token"), params.OperationID)
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
if !ok {
|
|
|
|
errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
|
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
|
|
log.NewError(params.OperationID, errMsg)
|
|
|
|
log.NewError(req.OperationID, errMsg)
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resp := api.ParseTokenResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, ExpireTime: api.ExpireTime{ExpireTimeSeconds: uint32(expireTime)}}
|
|
|
|
log.NewInfo(req.OperationID, "ForceLogout args ", req.String())
|
|
|
|
resp.Data = structs.Map(&resp.ExpireTime)
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
|
|
|
log.NewInfo(params.OperationID, "ParseToken return ", resp)
|
|
|
|
client := rpc.NewAuthClient(etcdConn)
|
|
|
|
c.JSON(http.StatusOK, resp)
|
|
|
|
reply, err := client.ForceLogout(context.Background(), req)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
errMsg := req.OperationID + " UserToken failed " + err.Error() + req.String()
|
|
|
|
|
|
|
|
log.NewError(req.OperationID, errMsg)
|
|
|
|
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), " return ", reply)
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, reply)
|
|
|
|
}
|
|
|
|
}
|
|
|
|