|
|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
|
api "Open_IM/pkg/base_info"
|
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
|
"Open_IM/pkg/common/token_verify"
|
|
|
|
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
|
|
|
rpc "Open_IM/pkg/proto/auth"
|
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
@ -96,3 +97,28 @@ func UserToken(c *gin.Context) {
|
|
|
|
|
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
|
|
|
|
c.JSON(http.StatusOK, resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ParseToken(c *gin.Context) {
|
|
|
|
|
params := api.ParseTokenReq{}
|
|
|
|
|
if err := c.BindJSON(¶ms); err != nil {
|
|
|
|
|
errMsg := " BindJSON failed " + err.Error()
|
|
|
|
|
log.NewError("0", errMsg)
|
|
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ok bool
|
|
|
|
|
var errInfo string
|
|
|
|
|
var expireTime int64
|
|
|
|
|
ok, _, errInfo, expireTime = token_verify.GetUserIDFromTokenExpireTime(c.Request.Header.Get("token"), params.OperationID)
|
|
|
|
|
if !ok {
|
|
|
|
|
errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
|
|
|
log.NewError(params.OperationID, errMsg)
|
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resp := api.ParseTokenResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, ExpireTime: expireTime}
|
|
|
|
|
log.NewInfo(params.OperationID, "ParseToken return ", resp)
|
|
|
|
|
c.JSON(http.StatusOK, resp)
|
|
|
|
|
}
|
|
|
|
|