validateRespWithRequest checks if the response matches the expected userID and platformID.
(ctx *UserConnContext, resp *pbAuth.ParseTokenResp)
| 448 | |
| 449 | // validateRespWithRequest checks if the response matches the expected userID and platformID. |
| 450 | func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error { |
| 451 | userID := ctx.GetUserID() |
| 452 | platformID := ctx.GetPlatformID() |
| 453 | if resp.UserID != userID { |
| 454 | return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID)) |
| 455 | } |
| 456 | if int(resp.PlatformID) != platformID { |
| 457 | return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token platform %d != platformID %d", resp.PlatformID, platformID)) |
| 458 | } |
| 459 | return nil |
| 460 | } |
| 461 | |
| 462 | func (ws *WsServer) handlerError(ctx *UserConnContext, w http.ResponseWriter, r *http.Request, err error) { |
| 463 | if !ctx.ShouldSendResp() { |
no test coverage detected