#81 start/due name changed in put request, little changes in authAuthor)rExecutor

parent 228d63a9
......@@ -24,6 +24,8 @@ export const auth = async(req: Request,res: Response, next:NextFunction):Promise
export const authAuthorOrExecutorOfTask = async(req: Request,res: Response, next:NextFunction):Promise<void | express.Response<Response>>=>{
const token = req.get('Authorization');
const {taskId} = req.body
console.log('taskId ', taskId)
if(!token) return res.status(401).send({Message:'token not exists'})
req.body={...req.body,executorStatus:false}
req.body={...req.body,authorStatus:false}
......@@ -34,6 +36,7 @@ export const authAuthorOrExecutorOfTask = async(req: Request,res: Response, next
.from(User, "user")
.leftJoinAndSelect("user.tasks", "task")
.where("user.token = :token", { token: token })
.andWhere("task.id =:taskId", {taskId})
.getOne();
console.log('executor', executor)
if (executor) {
......@@ -45,6 +48,7 @@ export const authAuthorOrExecutorOfTask = async(req: Request,res: Response, next
.from(User, "user")
.leftJoinAndSelect("user.createdTasks", "task")
.where("user.token = :token", { token: token })
.andWhere("task.id =:taskId", {taskId})
.getOne();
console.log('author', author)
if (author) {
......
......@@ -153,7 +153,7 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
/**change of task by task id */
router.put('/',authAuthorOrExecutorOfTask,async(req:Request, res:Response)=> {
const {authorStatus,executorStatus,taskId,title,description,note, archive,project,dateTimeTaskId,start,due,executor,accomplish,dateTimeDeadLine, dateTimeFactDeadLine,priority} = req.body;
const {authorStatus,executorStatus,taskId,title,description,note, archive,project,dateTimeTaskId,dateTimeStart,dateTimeDue,executor,accomplish,dateTimeDeadLine, dateTimeFactDeadLine,priority} = req.body;
const task = await taskFinderById(taskId)
if (!task) return res.status(404).send({Message:'task not found'})
let dateTimeTask = null;
......@@ -178,8 +178,8 @@ router.put('/',authAuthorOrExecutorOfTask,async(req:Request, res:Response)=> {
task.priority= priority
}
if(executorStatus && dateTimeTask!==null){
dateTimeTask.dateTimeStart = start
dateTimeTask.dateTimeDue = due
dateTimeTask.dateTimeStart = dateTimeStart
dateTimeTask.dateTimeDue = dateTimeDue
await dateTimeTask.save()
task.note = note
task.dateTimeFactDeadLine= dateTimeFactDeadLine
......
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