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

Function UserHasDocAccess

db/changes.go:383–398  ·  view source on GitHub ↗

UserHasDocAccess checks whether the user has access to the active revision of the document

(ctx context.Context, collection *DatabaseCollectionWithUser, docID string)

Source from the content-addressed store, hash-verified

381
382// UserHasDocAccess checks whether the user has access to the active revision of the document
383func UserHasDocAccess(ctx context.Context, collection *DatabaseCollectionWithUser, docID string) (bool, error) {
384 currentRev, err := collection.revisionCache.GetActive(ctx, docID)
385 if err != nil {
386 if base.IsDocNotFoundError(err) {
387 return false, nil
388 }
389 return false, err
390 }
391
392 if collection.user == nil {
393 return true, nil
394 }
395
396 authErr := collection.user.AuthorizeAnyCollectionChannel(collection.ScopeName, collection.Name, currentRev.Channels)
397 return authErr == nil, nil
398}
399
400// Checks if a document needs to be revoked. This is used in the case where the since < doc sequence
401func (col *DatabaseCollectionWithUser) wasDocInChannelPriorToRevocation(ctx context.Context, syncData SyncData, docID, chanName string, since uint64) (bool, error) {

Callers 3

buildRevokedFeedMethod · 0.85
sendChangesMethod · 0.85

Calls 3

IsDocNotFoundErrorFunction · 0.92
GetActiveMethod · 0.65

Tested by 1