|
|
@ -21,19 +21,13 @@ if (Meteor.isServer) { |
|
|
|
// We authorize the attachment download either:
|
|
|
|
// We authorize the attachment download either:
|
|
|
|
// - if the board is public, everyone (even unconnected) can download it
|
|
|
|
// - if the board is public, everyone (even unconnected) can download it
|
|
|
|
// - if the board is private, only board members can download it
|
|
|
|
// - if the board is private, only board members can download it
|
|
|
|
//
|
|
|
|
|
|
|
|
// XXX We have a bug with the `userId` verification:
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// https://github.com/CollectionFS/Meteor-CollectionFS/issues/449
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
download(userId, doc) { |
|
|
|
download(userId, doc) { |
|
|
|
const query = { |
|
|
|
const board = Boards.findOne(doc.boardId); |
|
|
|
$or: [ |
|
|
|
if (board.isPublic()) { |
|
|
|
{ 'members.userId': userId }, |
|
|
|
return true; |
|
|
|
{ permission: 'public' }, |
|
|
|
} else { |
|
|
|
], |
|
|
|
return board.hasMember(userId); |
|
|
|
}; |
|
|
|
} |
|
|
|
return Boolean(Boards.findOne(doc.boardId, query)); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fetch: ['boardId'], |
|
|
|
fetch: ['boardId'], |
|
|
|