Returns an HTTP 403 error if the User is not allowed to access any of this revision's channels.
(doc *Document, revid string)
| 672 | |
| 673 | // Returns an HTTP 403 error if the User is not allowed to access any of this revision's channels. |
| 674 | func (col *DatabaseCollectionWithUser) authorizeDoc(doc *Document, revid string) error { |
| 675 | user := col.user |
| 676 | if doc == nil || user == nil { |
| 677 | return nil // A nil User means access control is disabled |
| 678 | } |
| 679 | |
| 680 | if revChannels, ok := doc.channelsForRevTreeID(revid); ok { |
| 681 | // Authenticate against specific revision: |
| 682 | return col.user.AuthorizeAnyCollectionChannel(col.ScopeName, col.Name, revChannels) |
| 683 | } else { |
| 684 | // No such revision; let the caller proceed and return a 404 |
| 685 | return nil |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | // Gets a revision of a document. If it's obsolete it will be loaded from the database if possible. |
| 690 | // inline "_attachments" properties in the body will be extracted and returned separately if present (pre-2.5 metadata, or backup revisions) |
no test coverage detected