fixing grant deletion

This commit is contained in:
Arjun Patel
2019-02-01 12:17:43 -08:00
parent 5af606e4eb
commit 49c470ab47
2 changed files with 5 additions and 7 deletions
+4 -2
View File
@@ -61,14 +61,16 @@ exports.findByDonorId = (req, res, next) => {
};
exports.delete = (req, res, next) => {
const grant_id = req.params.grant_id;
const { grant_id } = req.body;
const user = req.user;
Grant.destroy({ where: { id: grant_id } })
Grant.destroy({ where: { id: grant_id, donor_id: user.id } })
.then(result => {
var message = 'Already Deleted';
if (result) {
message = 'Grant Deleted';
}
res.status(201).json({
result,
message