#95 added check on create new copytask

parent 4a12c42e
...@@ -92,6 +92,7 @@ export const authAuthorOrExecutorOfDateTimeTask = async(req: Request,res: Respon ...@@ -92,6 +92,7 @@ export const authAuthorOrExecutorOfDateTimeTask = async(req: Request,res: Respon
.leftJoinAndSelect("task.author","users") .leftJoinAndSelect("task.author","users")
.where("dateTimeTask.id = :dateTimeTaskId", {dateTimeTaskId}) .where("dateTimeTask.id = :dateTimeTaskId", {dateTimeTaskId})
.getOne() .getOne()
if (!task) return res.status(404).send({message:'task with possible user involved is not found'}) if (!task) return res.status(404).send({message:'task with possible user involved is not found'})
if(task?.executor?.token === token) { if(task?.executor?.token === token) {
......
...@@ -28,14 +28,15 @@ const taskFinderById = async (taskId:string):Promise<null | Task>=>{ ...@@ -28,14 +28,15 @@ const taskFinderById = async (taskId:string):Promise<null | Task>=>{
} }
/** make copy of task in calendar view */ /** make copy of task in calendar view */
router.post("/make-copy", async(req:Request, res:Response):Promise<Response>=>{ router.post("/make-copy",authAuthorOrExecutorOfTask, async(req:Request, res:Response):Promise<Response>=>{
const {taskId, dateTimeDue, dateTimeStart} = req.body 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(); const newDateTimeTask = new DateTimeTask();
newDateTimeTask.dateTimeStart = dateTimeStart newDateTimeTask.dateTimeStart = dateTimeStart;
newDateTimeTask.dateTimeDue = dateTimeDue newDateTimeTask.dateTimeDue = dateTimeDue;
newDateTimeTask.task = taskId newDateTimeTask.task = taskId;
await newDateTimeTask.save() await newDateTimeTask.save();
const task = taskFinderById(taskId)
return res.send({task}) 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