Skip to content

Commit

Permalink
Merge pull request #33 from Turistforeningen/fix/leave-nonexisting-list
Browse files Browse the repository at this point in the history
fix(profile): fix bug when leaving list twice
  • Loading branch information
Håvard Ranum authored Sep 6, 2016
2 parents f0b1860 + 8102526 commit eea3052
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ router.post('/lister/:liste/blimed', requireAuth, (req, res) => {

router.post('/lister/:liste/meldav', requireAuth, (req, res) => {
const user = req.user;
user.lister.splice(user.lister.indexOf(req.params.liste), 1);
if (user.lister.indexOf(req.params.liste) > -1) {
user.lister.splice(user.lister.indexOf(req.params.liste), 1);
}
user.save();
res.json({
message: 'Ok',
Expand Down

0 comments on commit eea3052

Please sign in to comment.