Skip to content

Commit

Permalink
Fix authorization bug in deleteTask function
Browse files Browse the repository at this point in the history
  • Loading branch information
realabdullah committed Dec 2, 2023
1 parent 92d5c74 commit 47ca1ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/controllers/taskController.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ export const fetchWorkspaceTask = async (req, res) => {
export const deleteTask = async (req, res) => {
try {
const {slug, id} = req.params;
const user = req.user;
const workspace = await Workspace.findOne({slug});
if (workspace.user.toString() !== user._id.toString()) {
throw new Error('You are not authorized to perform this action');
}
const task = await Task.findOneAndDelete({
user: req.user._id,
user: user._id,
_id: id,
workspace: workspace._id,
});
Expand Down

0 comments on commit 47ca1ee

Please sign in to comment.