#95 added check on create new copytask

parent 4a12c42e
......@@ -92,6 +92,7 @@ export const authAuthorOrExecutorOfDateTimeTask = async(req: Request,res: Respon
.leftJoinAndSelect("task.author","users")
.where("dateTimeTask.id = :dateTimeTaskId", {dateTimeTaskId})
.getOne()
if (!task) return res.status(404).send({message:'task with possible user involved is not found'})
if(task?.executor?.token === token) {
......
......@@ -28,14 +28,15 @@ const taskFinderById = async (taskId:string):Promise<null | Task>=>{
}
/** make copy of task in calendar view */
router.post("/make-copy", async(req:Request, res:Response):Promise<Response>=>{
const {taskId, dateTimeDue, dateTimeStart} = req.body
router.post("/make-copy",authAuthorOrExecutorOfTask, async(req:Request, res:Response):Promise<Response>=>{
const {taskId, dateTimeDue, dateTimeStart} = req.body;
const task = await taskFinderById(taskId);
if(!task) return res.status(401).send({message:'task with possible user involved is not found'})
const newDateTimeTask = new DateTimeTask();
newDateTimeTask.dateTimeStart = dateTimeStart
newDateTimeTask.dateTimeDue = dateTimeDue
newDateTimeTask.task = taskId
await newDateTimeTask.save()
const task = taskFinderById(taskId)
newDateTimeTask.dateTimeStart = dateTimeStart;
newDateTimeTask.dateTimeDue = dateTimeDue;
newDateTimeTask.task = taskId;
await newDateTimeTask.save();
return res.send({task})
} )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment