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