Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(entity => {
if (!entity)
return this.Promise.reject(new MoleculerClientError("Article not found!", 404));
if (entity.author !== ctx.meta.user._id)
return this.Promise.reject(new ForbiddenError());
return this.adapter.removeById(entity._id)
.then(() => ctx.call("favorites.removeByArticle", { article: entity._id }));
});
}
.then(comment => {
if (comment.author !== ctx.meta.user._id)
return this.Promise.reject(new ForbiddenError());
return this.adapter.removeById(ctx.params.id);
});
}