mirror of
https://github.com/wekan/wekan.git
synced 2025-04-24 14:08:31 -04:00
Extracted board access check function
This commit is contained in:
parent
95e2025ff9
commit
1e8d9f02f3
2 changed files with 10 additions and 4 deletions
|
@ -588,11 +588,8 @@ if (Meteor.isServer) {
|
|||
});
|
||||
|
||||
JsonRoutes.add('GET', '/api/boards/:id', function (req, res, next) {
|
||||
Authentication.checkLoggedIn( req.userId);
|
||||
const id = req.params.id;
|
||||
const board = Boards.findOne({ _id: id });
|
||||
const normalAccess = board.permission === 'public' || board.members.some(e => e._id === req.userId);
|
||||
Authentication.checkAdminOrCondition(req.userId, normalAccess);
|
||||
Authentication.checkBoardAccess( req.userId, id);
|
||||
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue