Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
fix: Can't set headers after they are sent
  • Loading branch information
Alberto Valero committed Apr 15, 2018
2 parents 21c5539 + 4f8e507 commit 04bb7f5
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions app/api/project/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,10 @@ exports.share = function (req, res) {
} else {
if (project && project.isOwner(userId)) {
project.resetShare();
async.map(emails, function (email, done) {
async.map(emails, function (email, next) {
email = email.toLowerCase();
if (email === req.user.email) {
done();
next();
} else {
UserFunctions.getUserId(email, function (err, user) {
if (user) {
Expand All @@ -627,21 +627,13 @@ exports.share = function (req, res) {
} else {
locals.projectUrl = config.client_domain + '#/login?init=/bloqsproject/' + projectId;
}

mailer.sendOne('shareProject', locals, function (err) {
if (err) {
console.log(err);
err.code = utils.getValidHttpErrorCode(err);
res.status(err.code).send(err);
} else {
res.status(200);
}
});
response.users.push(email);
mailer.sendOne('shareProject', locals, next);

} else if (!err) {
response.noUsers.push(email);
next();
}
done(err);
});
}
},
Expand Down Expand Up @@ -856,4 +848,4 @@ exports.createAll = function (req, res) {
}
});

};
};

0 comments on commit 04bb7f5

Please sign in to comment.