Updated login headers save. Added task service to user service. Sync user tasks

This commit is contained in:
Keith Holliday
2016-05-09 23:31:34 -05:00
parent a92359e119
commit a0939155c9
13 changed files with 107 additions and 86 deletions

View File

@@ -6,16 +6,15 @@ import _ from 'lodash';
module.exports = function deleteTask (user, req = {}) {
let tid = _.get(req, 'params.id');
let task = user.tasks[tid];
let taskType = _.get(req, 'params.taskType');
if (!task) {
let index = _.findIndex(user[`${taskType}s`], function(task) {return task._id === tid;});
if (index === -1) {
throw new NotFound(i18n.t('messageTaskNotFound', req.language));
}
let index = user[`${task.type}s`].indexOf(task);
if (index !== -1) {
user[`${task.type}s`].splice(index, 1);
}
user[`${taskType}s`].splice(index, 1);
return {};
};