|
|
|
@ -197,11 +197,11 @@ func ParseToken(tokensString, operationID string) (claims *Claims, err error) {
|
|
|
|
|
m, err := commonDB.DB.GetTokenMapByUidPid(claims.UID, claims.Platform)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.NewError(operationID, "get token from redis err", err.Error(), tokensString)
|
|
|
|
|
return nil, utils.Wrap(&constant.ErrTokenInvalid, "get token from redis err")
|
|
|
|
|
return nil, utils.Wrap(constant.ErrTokenInvalid, "get token from redis err")
|
|
|
|
|
}
|
|
|
|
|
if m == nil {
|
|
|
|
|
log.NewError(operationID, "get token from redis err, not in redis ", "m is nil", tokensString)
|
|
|
|
|
return nil, utils.Wrap(&constant.ErrTokenInvalid, "get token from redis err")
|
|
|
|
|
return nil, utils.Wrap(constant.ErrTokenInvalid, "get token from redis err")
|
|
|
|
|
}
|
|
|
|
|
if v, ok := m[tokensString]; ok {
|
|
|
|
|
switch v {
|
|
|
|
@ -210,13 +210,13 @@ func ParseToken(tokensString, operationID string) (claims *Claims, err error) {
|
|
|
|
|
return claims, nil
|
|
|
|
|
case constant.KickedToken:
|
|
|
|
|
log.Error(operationID, "this token has been kicked by other same terminal ", constant.ErrTokenKicked)
|
|
|
|
|
return nil, utils.Wrap(&constant.ErrTokenKicked, "this token has been kicked by other same terminal ")
|
|
|
|
|
return nil, utils.Wrap(constant.ErrTokenKicked, "this token has been kicked by other same terminal ")
|
|
|
|
|
default:
|
|
|
|
|
return nil, utils.Wrap(&constant.ErrTokenUnknown, "")
|
|
|
|
|
return nil, utils.Wrap(constant.ErrTokenUnknown, "")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.NewError(operationID, "redis token map not find", constant.ErrTokenUnknown)
|
|
|
|
|
return nil, utils.Wrap(&constant.ErrTokenUnknown, "redis token map not find")
|
|
|
|
|
return nil, utils.Wrap(constant.ErrTokenUnknown, "redis token map not find")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//func MakeTheTokenInvalid(currentClaims *Claims, platformClass string) (bool, error) {
|
|
|
|
@ -254,7 +254,7 @@ func VerifyToken(token, uid string) (bool, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func WsVerifyToken(token, uid string, platformID string, operationID string) (bool, error, string) {
|
|
|
|
|
argMsg := "token: " + token + " operationID: " + operationID + " userID: " + uid + " platformID: " + platformID
|
|
|
|
|
argMsg := "token: " + token + " operationID: " + operationID + " userID: " + uid + " platformID: " + constant.PlatformIDToName(utils.StringToInt(platformID)
|
|
|
|
|
claims, err := ParseToken(token, operationID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
//if errors.Is(err, constant.ErrTokenUnknown) {
|
|
|
|
@ -275,7 +275,7 @@ func WsVerifyToken(token, uid string, platformID string, operationID string) (bo
|
|
|
|
|
return false, utils.Wrap(constant.ErrTokenDifferentUserID, errMsg), errMsg
|
|
|
|
|
}
|
|
|
|
|
if claims.Platform != constant.PlatformIDToName(utils.StringToInt(platformID)) {
|
|
|
|
|
errMsg := " platform is not same to token platform " + argMsg + "claims platformID " + claims.Platform
|
|
|
|
|
errMsg := " platform is not same to token platform " + argMsg + " claims platformID " + claims.Platform
|
|
|
|
|
return false, utils.Wrap(constant.ErrTokenDifferentPlatformID, errMsg), errMsg
|
|
|
|
|
}
|
|
|
|
|
log.NewDebug(operationID, utils.GetSelfFuncName(), " check ok ", claims.UID, uid, claims.Platform)
|
|
|
|
|