Extracted board access check function

This commit is contained in:
mayjs 2017-05-15 21:02:31 +02:00
parent 95e2025ff9
commit 1e8d9f02f3
2 changed files with 10 additions and 4 deletions

View file

@ -39,5 +39,14 @@ Meteor.startup(() => {
}
}
// Helper function. Will throw an error if the user does not have read only access to the given board
Authentication.checkBoardAccess = function(userId, boardId) {
Authentication.checkLoggedIn(userId);
const board = Boards.findOne({ _id: boardId });
const normalAccess = board.permission === 'public' || board.members.some(e => e.userId === userId);
Authentication.checkAdminOrCondition(userId, normalAccess);
}
});