MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / authorizeUserForChannels

Method authorizeUserForChannels

db/crud.go:621–647  ·  view source on GitHub ↗
(docID, revID string, cv *Version, channels base.Set, isDeleted bool, history Revisions)

Source from the content-addressed store, hash-verified

619}
620
621func (col *DatabaseCollectionWithUser) authorizeUserForChannels(docID, revID string, cv *Version, channels base.Set, isDeleted bool, history Revisions) (isAuthorized bool, redactedRev DocumentRevision) {
622
623 if col.user != nil {
624 if err := col.user.AuthorizeAnyCollectionChannel(col.ScopeName, col.Name, channels); err != nil {
625 // On access failure, return (only) the doc history and deletion/removal
626 // status instead of returning an error. For justification see the comment in
627 // the getRevFromDoc method, below
628 redactedRev = DocumentRevision{
629 DocID: docID,
630 RevID: revID,
631 History: history,
632 Deleted: isDeleted,
633 CV: cv,
634 }
635 if isDeleted {
636 // Deletions are denoted by the deleted message property during 2.x replication
637 redactedRev.BodyBytes = []byte(base.EmptyDocument)
638 } else {
639 // ... but removals are still denoted by the _removed property in the body, even for 2.x replication
640 redactedRev.BodyBytes = []byte(RemovedRedactedDocument)
641 }
642 return false, redactedRev
643 }
644 }
645
646 return true, DocumentRevision{}
647}
648
649// Returns the body of a revision of a document, as well as the document's current channels
650// and the user/roles it grants channel access to.

Callers 2

GetDeltaMethod · 0.95

Calls 1

Tested by

no test coverage detected