From 0b4b1ae584decaecc87916b991ceff3fb29bc13d Mon Sep 17 00:00:00 2001 From: Ben Brooks Date: Wed, 13 Sep 2023 15:30:49 +0100 Subject: [PATCH] Handle winning revision logic in authorizeDoc --- db/crud.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/crud.go b/db/crud.go index a6d38ee959..146970cba7 100644 --- a/db/crud.go +++ b/db/crud.go @@ -550,7 +550,16 @@ func (col *DatabaseCollectionWithUser) authorizeDoc(doc *Document, revid string) if revid == "" { revid = doc.CurrentRev } - if rev := doc.History[revid]; rev != nil { + + if revid == doc.CurrentRev { + ch := base.SetOf() + for channelName, channelRemoval := range doc.Channels { + if channelRemoval == nil || channelRemoval.Seq == 0 { + ch.Add(channelName) + } + } + return col.user.AuthorizeAnyCollectionChannel(col.ScopeName, col.Name, ch) + } else if rev := doc.History[revid]; rev != nil { // Authenticate against specific revision: return col.user.AuthorizeAnyCollectionChannel(col.ScopeName, col.Name, rev.Channels) } else {