Fix missing profile checks

This commit is contained in:
Justin Reynolds 2019-05-08 16:51:27 -05:00
parent 97ff2bd2fa
commit daf314b037
12 changed files with 39 additions and 35 deletions

View file

@ -172,7 +172,7 @@ export class Exporter {
};
result.users = Users.find(byUserIds, userFields).fetch().map((user) => {
// user avatar is stored as a relative url, we export absolute
if (user.profile.avatarUrl) {
if ((user.profile || {}).avatarUrl) {
user.profile.avatarUrl = FlowRouter.url(user.profile.avatarUrl);
}
return user;

View file

@ -168,17 +168,17 @@ Swimlanes.helpers({
isListTemplatesSwimlane() {
const user = Users.findOne(Meteor.userId());
return user.profile.listTemplatesSwimlaneId === this._id;
return (user.profile || {}).listTemplatesSwimlaneId === this._id;
},
isCardTemplatesSwimlane() {
const user = Users.findOne(Meteor.userId());
return user.profile.cardTemplatesSwimlaneId === this._id;
return (user.profile || {}).cardTemplatesSwimlaneId === this._id;
},
isBoardTemplatesSwimlane() {
const user = Users.findOne(Meteor.userId());
return user.profile.boardTemplatesSwimlaneId === this._id;
return (user.profile || {}).boardTemplatesSwimlaneId === this._id;
},
remove() {

View file

@ -288,32 +288,32 @@ Users.helpers({
},
starredBoards() {
const {starredBoards = []} = this.profile;
const {starredBoards = []} = this.profile || {};
return Boards.find({archived: false, _id: {$in: starredBoards}});
},
hasStarred(boardId) {
const {starredBoards = []} = this.profile;
const {starredBoards = []} = this.profile || {};
return _.contains(starredBoards, boardId);
},
invitedBoards() {
const {invitedBoards = []} = this.profile;
const {invitedBoards = []} = this.profile || {};
return Boards.find({archived: false, _id: {$in: invitedBoards}});
},
isInvitedTo(boardId) {
const {invitedBoards = []} = this.profile;
const {invitedBoards = []} = this.profile || {};
return _.contains(invitedBoards, boardId);
},
hasTag(tag) {
const {tags = []} = this.profile;
const {tags = []} = this.profile || {};
return _.contains(tags, tag);
},
hasNotification(activityId) {
const {notifications = []} = this.profile;
const {notifications = []} = this.profile || {};
return _.contains(notifications, activityId);
},
@ -323,7 +323,7 @@ Users.helpers({
},
getEmailBuffer() {
const {emailBuffer = []} = this.profile;
const {emailBuffer = []} = this.profile || {};
return emailBuffer;
},
@ -358,11 +358,11 @@ Users.helpers({
},
getTemplatesBoardId() {
return this.profile.templatesBoardId;
return (this.profile || {}).templatesBoardId;
},
getTemplatesBoardSlug() {
return Boards.findOne(this.profile.templatesBoardId).slug;
return (Boards.findOne((this.profile || {}).templatesBoardId) || {}).slug;
},
});