|
|
|
@ -180,18 +180,18 @@ func ParseTokenGetUserID(token string, operationID string) (error, string) {
|
|
|
|
|
func ParseToken(tokensString, operationID string) (claims *Claims, err error) {
|
|
|
|
|
claims, err = GetClaimFromToken(tokensString)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if errors.Is(err, constant.ErrTokenUnknown) {
|
|
|
|
|
errMsg := "GetClaimFromToken failed ErrTokenUnknown " + err.Error()
|
|
|
|
|
log.Error(operationID, errMsg)
|
|
|
|
|
}
|
|
|
|
|
info := err.(constant.ErrInfo)
|
|
|
|
|
log.Error(operationID, "detail info , ", info.ErrCode, info.ErrMsg)
|
|
|
|
|
|
|
|
|
|
e := errors.Unwrap(err)
|
|
|
|
|
if errors.Is(e, constant.ErrTokenUnknown) {
|
|
|
|
|
errMsg := "ParseToken failed ErrTokenUnknown " + e.Error()
|
|
|
|
|
log.Error(operationID, errMsg)
|
|
|
|
|
}
|
|
|
|
|
//if errors.Is(err, constant.ErrTokenUnknown) {
|
|
|
|
|
// errMsg := "GetClaimFromToken failed ErrTokenUnknown " + err.Error()
|
|
|
|
|
// log.Error(operationID, errMsg)
|
|
|
|
|
//}
|
|
|
|
|
//info := err.(constant.ErrInfo)
|
|
|
|
|
//log.Error(operationID, "detail info , ", info.ErrCode, info.ErrMsg)
|
|
|
|
|
//
|
|
|
|
|
//e := errors.Unwrap(err)
|
|
|
|
|
//if errors.Is(e, constant.ErrTokenUnknown) {
|
|
|
|
|
// errMsg := "ParseToken failed ErrTokenUnknown " + e.Error()
|
|
|
|
|
// log.Error(operationID, errMsg)
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
log.NewError(operationID, "token validate err", err.Error(), tokensString, "type ", reflect.TypeOf(err), "type2: ", reflect.TypeOf(e))
|
|
|
|
|
return nil, utils.Wrap(err, "")
|
|
|
|
@ -260,15 +260,15 @@ func WsVerifyToken(token, uid string, platformID string, operationID string) (bo
|
|
|
|
|
argMsg := "token: " + token + " operationID: " + operationID + " userID: " + uid + " platformID: " + platformID
|
|
|
|
|
claims, err := ParseToken(token, operationID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if errors.Is(err, constant.ErrTokenUnknown) {
|
|
|
|
|
errMsg := "ParseToken failed ErrTokenUnknown " + err.Error()
|
|
|
|
|
log.Error(operationID, errMsg)
|
|
|
|
|
}
|
|
|
|
|
e := errors.Unwrap(err)
|
|
|
|
|
if errors.Is(e, constant.ErrTokenUnknown) {
|
|
|
|
|
errMsg := "ParseToken failed ErrTokenUnknown " + e.Error()
|
|
|
|
|
log.Error(operationID, errMsg)
|
|
|
|
|
}
|
|
|
|
|
//if errors.Is(err, constant.ErrTokenUnknown) {
|
|
|
|
|
// errMsg := "ParseToken failed ErrTokenUnknown " + err.Error()
|
|
|
|
|
// log.Error(operationID, errMsg)
|
|
|
|
|
//}
|
|
|
|
|
//e := errors.Unwrap(err)
|
|
|
|
|
//if errors.Is(e, constant.ErrTokenUnknown) {
|
|
|
|
|
// errMsg := "ParseToken failed ErrTokenUnknown " + e.Error()
|
|
|
|
|
// log.Error(operationID, errMsg)
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
errMsg := "parse token err " + err.Error() + argMsg
|
|
|
|
|
return false, utils.Wrap(err, errMsg), errMsg
|
|
|
|
|