Skip to content

Commit

Permalink
Handle winning revision logic in authorizeDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Sep 13, 2023
1 parent db7a319 commit 0b4b1ae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion db/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0b4b1ae

Please sign in to comment.