summaryrefslogtreecommitdiffstats
path: root/models/users.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-10-28 23:36:04 +0100
committerMaxime Quandalle <maxime@quandalle.com>2015-10-28 23:36:04 +0100
commitaae5030b53d644649e9b8cd2e2a03ec843a13162 (patch)
tree9e440d50b108b6ca4806fe1447fb4d59d0f4b72d /models/users.js
parent31b60d82fcae64a844805a2a76a0af25fb9c16c2 (diff)
parentc9130324f6c337d0393bf37fe72b67b47ece8322 (diff)
downloadwekan-aae5030b53d644649e9b8cd2e2a03ec843a13162.tar.gz
wekan-aae5030b53d644649e9b8cd2e2a03ec843a13162.tar.bz2
wekan-aae5030b53d644649e9b8cd2e2a03ec843a13162.zip
Merge pull request #370 from dferber90/linter
Add ESLint-plugin-Meteor
Diffstat (limited to 'models/users.js')
-rw-r--r--models/users.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/models/users.js b/models/users.js
index b35104ec..1e69564d 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,6 +8,24 @@ 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() {
return Boards.find({ userId: this._id });
@@ -23,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.