Skip to content

Commit a47d2e6

Browse files
committed
make server subs subscribe logic symmetrical to client side subs
1 parent 46ae012 commit a47d2e6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

internal/client/handler.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ func (h *Handler) OnClientConnecting(
403403

404404
var channelOk bool
405405

406-
isUserLimited := h.cfgContainer.IsUserLimited(ch)
407-
isPrivate := h.cfgContainer.IsPrivateChannel(ch)
406+
isPrivateChannel := h.cfgContainer.IsPrivateChannel(ch)
407+
isUserLimitedChannel := h.cfgContainer.IsUserLimited(ch) && chOpts.UserLimitedChannels
408408

409409
var userID string
410410
if credentials != nil {
@@ -416,10 +416,12 @@ func (h *Handler) OnClientConnecting(
416416
return centrifuge.ConnectReply{}, centrifuge.ErrorInternal
417417
}
418418

419-
if !isPrivate && !chOpts.SubscribeProxyEnabled && validChannelName {
420-
if isUserLimited && chOpts.UserLimitedChannels && (userID != "" && h.cfgContainer.UserAllowed(ch, userID)) {
419+
if !isPrivateChannel && !chOpts.SubscribeProxyEnabled && validChannelName {
420+
if isUserLimitedChannel && (userID != "" && h.cfgContainer.UserAllowed(ch, userID)) {
421421
channelOk = true
422-
} else if chOpts.SubscribeForClient && (userID != "" || chOpts.SubscribeForAnonymous) {
422+
} else if chOpts.SubscribeForClient && (userID != "" || chOpts.SubscribeForAnonymous) && !isUserLimitedChannel {
423+
channelOk = true
424+
} else if cfg.Client.Insecure {
423425
channelOk = true
424426
}
425427
}

0 commit comments

Comments
 (0)