MCPcopy
hub / github.com/openimsdk/open-im-server / validateRespWithRequest

Method validateRespWithRequest

internal/msggateway/ws_server.go:450–460  ·  view source on GitHub ↗

validateRespWithRequest checks if the response matches the expected userID and platformID.

(ctx *UserConnContext, resp *pbAuth.ParseTokenResp)

Source from the content-addressed store, hash-verified

448
449// validateRespWithRequest checks if the response matches the expected userID and platformID.
450func (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
462func (ws *WsServer) handlerError(ctx *UserConnContext, w http.ResponseWriter, r *http.Request, err error) {
463 if !ctx.ShouldSendResp() {

Callers 1

wsHandlerMethod · 0.95

Calls 2

GetPlatformIDMethod · 0.80
GetUserIDMethod · 0.65

Tested by

no test coverage detected