Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
d26f6c4f
Commit
d26f6c4f
authored
Nov 30, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#81
start/due name changed in put request, little changes in authAuthor)rExecutor
parent
228d63a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
helpers.ts
planner-api/src/helpers.ts
+4
-0
tasks.ts
planner-api/src/routers/tasks.ts
+3
-3
No files found.
planner-api/src/helpers.ts
View file @
d26f6c4f
...
...
@@ -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
)
{
...
...
planner-api/src/routers/tasks.ts
View file @
d26f6c4f
...
...
@@ -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
,
d
ue
,
executor
,
accomplish
,
dateTimeDeadLine
,
dateTimeFactDeadLine
,
priority
}
=
req
.
body
;
const
{
authorStatus
,
executorStatus
,
taskId
,
title
,
description
,
note
,
archive
,
project
,
dateTimeTaskId
,
dateTimeStart
,
dateTimeD
ue
,
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
=
s
tart
dateTimeTask
.
dateTimeDue
=
due
dateTimeTask
.
dateTimeStart
=
dateTimeS
tart
dateTimeTask
.
dateTimeDue
=
d
ateTimeD
ue
await
dateTimeTask
.
save
()
task
.
note
=
note
task
.
dateTimeFactDeadLine
=
dateTimeFactDeadLine
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment