diff options
author | Xavier Priour <xavier.priour@bubblyware.com> | 2015-11-13 12:43:34 +0100 |
---|---|---|
committer | Xavier Priour <xavier.priour@bubblyware.com> | 2015-11-13 12:43:34 +0100 |
commit | a7427b9ae4e790989c49408ffe14aea4976db305 (patch) | |
tree | 3b56c753ce05ba9a5253078e2792b2c485d2912e /models/users.js | |
parent | 3dc70b3ea4d49bccb10d4f2b3e317c794da91e37 (diff) | |
parent | cb3bd86396e4d19e1f05fcb94e3527f81e70412e (diff) | |
download | wekan-a7427b9ae4e790989c49408ffe14aea4976db305.tar.gz wekan-a7427b9ae4e790989c49408ffe14aea4976db305.tar.bz2 wekan-a7427b9ae4e790989c49408ffe14aea4976db305.zip |
merge with /devel
Diffstat (limited to 'models/users.js')
-rw-r--r-- | models/users.js | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/models/users.js b/models/users.js index 60cab56d..e85671bc 100644 --- a/models/users.js +++ b/models/users.js @@ -1,4 +1,4 @@ -Users = Meteor.users; +Users = Meteor.users; // eslint-disable-line meteor/collections // Search a user in the complete server database by its name or username. This // is used for instance to add a new user to a board. @@ -8,7 +8,23 @@ Users.initEasySearch(searchInFields, { returnFields: [...searchInFields, 'profile.avatarUrl'], }); - +if (Meteor.isClient) { + Users.helpers({ + isBoardMember() { + const board = Boards.findOne(Session.get('currentBoard')); + return board && + _.contains(_.pluck(board.members, 'userId'), this._id) && + _.where(board.members, {userId: this._id})[0].isActive; + }, + + isBoardAdmin() { + const board = Boards.findOne(Session.get('currentBoard')); + return board && + this.isBoardMember(board) && + _.where(board.members, {userId: this._id})[0].isAdmin; + }, + }); +} Users.helpers({ boards() { @@ -25,18 +41,6 @@ Users.helpers({ return _.contains(starredBoards, boardId); }, - isBoardMember() { - const board = Boards.findOne(Session.get('currentBoard')); - return board && _.contains(_.pluck(board.members, 'userId'), this._id) && - _.where(board.members, {userId: this._id})[0].isActive; - }, - - isBoardAdmin() { - const board = Boards.findOne(Session.get('currentBoard')); - return board && this.isBoardMember(board) && - _.where(board.members, {userId: this._id})[0].isAdmin; - }, - getAvatarUrl() { // Although we put the avatar picture URL in the `profile` object, we need // to support Sandstorm which put in the `picture` attribute by default. |