Skip to content

Commit

Permalink
Pass revision.RevID into authorizeUserForChannels
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Jan 17, 2024
1 parent f2510b6 commit ccb0553
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions db/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (db *DatabaseCollectionWithUser) getRev(ctx context.Context, docid, revid s
// documentRevisionForRequest processes the given DocumentRevision and returns a version of it for a given client request, depending on access, deleted, etc.
func (db *DatabaseCollectionWithUser) documentRevisionForRequest(ctx context.Context, docID string, revision DocumentRevision, revID *string, cv *Version, maxHistory int, historyFrom []string) (DocumentRevision, error) {
// ensure only one of cv or revID is specified
if (cv != nil && revID != nil) || (cv == nil && revID == nil) {
if cv != nil && revID != nil {
return DocumentRevision{}, fmt.Errorf("must have exactly one of cv or revID in documentRevisionForRequest (had %v %v)", cv, revID)
}
var requestedVersion string
Expand Down Expand Up @@ -363,8 +363,7 @@ func (db *DatabaseCollectionWithUser) documentRevisionForRequest(ctx context.Con
_, requestedHistory = trimEncodedRevisionsToAncestor(ctx, requestedHistory, historyFrom, maxHistory)
}

revIDStr := base.StringDefault(revID, "")
isAuthorized, redactedRevision := db.authorizeUserForChannels(docID, revIDStr, cv, revision.Channels, revision.Deleted, requestedHistory)
isAuthorized, redactedRevision := db.authorizeUserForChannels(docID, revision.RevID, cv, revision.Channels, revision.Deleted, requestedHistory)
if !isAuthorized {
// client just wanted active revision, not a specific one
if requestedVersion == "" {
Expand Down

0 comments on commit ccb0553

Please sign in to comment.