summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-09-30 02:37:16 +0300
committerLauri Ojansivu <x@xet7.org>2018-09-30 02:37:16 +0300
commit51ac6c839ecf2226b2a81b0d4f985d3b942f0938 (patch)
tree3443178fb92d31371bab6967f24ec73101f86ca5
parent3a3666312ff89e549adef6fa89f964d72e350d3b (diff)
downloadwekan-51ac6c839ecf2226b2a81b0d4f985d3b942f0938.tar.gz
wekan-51ac6c839ecf2226b2a81b0d4f985d3b942f0938.tar.bz2
wekan-51ac6c839ecf2226b2a81b0d4f985d3b942f0938.zip
- REST API: Change role on board. Docs: https://github.com/wekan/wekan/wiki/REST-API-Role
Thanks to entrptaher and xet7 !
-rw-r--r--models/boards.js30
1 files changed, 27 insertions, 3 deletions
diff --git a/models/boards.js b/models/boards.js
index 641ecdb9..52d0ca87 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -541,11 +541,10 @@ Boards.mutations({
};
},
- setMemberPermission(memberId, isAdmin, isNoComments, isCommentOnly) {
+ setMemberPermission(memberId, isAdmin, isNoComments, isCommentOnly, currentUserId = Meteor.userId()) {
const memberIndex = this.memberIndex(memberId);
-
// do not allow change permission of self
- if (memberId === Meteor.userId()) {
+ if (memberId === currentUserId) {
isAdmin = this.members[memberIndex].isAdmin;
}
@@ -927,4 +926,29 @@ if (Meteor.isServer) {
});
}
});
+
+ JsonRoutes.add('POST', '/api/boards/:boardId/members/:memberId', function (req, res) {
+ try {
+ const boardId = req.params.boardId;
+ const memberId = req.params.memberId;
+ const {isAdmin, isNoComments, isCommentOnly} = req.body;
+ Authentication.checkBoardAccess(req.userId, boardId);
+ const board = Boards.findOne({ _id: boardId });
+ function isTrue(data){
+ return data.toLowerCase() === 'true';
+ }
+ board.setMemberPermission(memberId, isTrue(isAdmin), isTrue(isNoComments), isTrue(isCommentOnly), req.userId);
+
+ JsonRoutes.sendResult(res, {
+ code: 200,
+ data: query,
+ });
+ }
+ catch (error) {
+ JsonRoutes.sendResult(res, {
+ code: 200,
+ data: error,
+ });
+ }
+ });
}