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
275cabde
Commit
275cabde
authored
Nov 05, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#23
fix routers/users/ login
parent
8aaec6f3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
users.ts
planner-api/src/routers/users.ts
+8
-13
No files found.
planner-api/src/routers/users.ts
View file @
275cabde
...
...
@@ -32,25 +32,20 @@ router.post('/', async (req : Request, res : Response):Promise<object> => {
router
.
post
(
'/sessions/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
console
.
log
(
'req.body'
,
req
.
body
)
const
user
:
User
|
null
=
await
dataSource
.
getRepository
(
User
)
const
{
email
,
password
}
=
req
.
body
;
const
user
=
await
dataSource
.
createQueryBuilder
()
.
select
()
.
addSelect
(
"User.password"
)
.
select
(
"user"
)
.
from
(
User
,
"user"
)
.
where
(
"user.email = :email"
,
{
email
:
email
})
.
getOne
()
if
(
!
user
)
return
res
.
status
(
404
).
send
({
Message
:
'user not found'
})
if
(
!
user
)
return
res
.
status
(
400
).
send
({
messageError
:
"User does not exist"
})
console
.
log
(
"user "
,
user
,
'req.body.password'
,
req
.
body
.
password
)
const
isMatch
:
boolean
=
await
user
.
checkPassword
(
req
.
body
.
password
);
if
(
!
isMatch
)
return
res
.
status
(
400
).
send
({
error
:
"Wrong Password"
})
const
isMatch
:
boolean
=
await
user
.
checkPassword
(
password
);
if
(
!
isMatch
)
return
res
.
status
(
400
).
send
({
error
:
"Wrong Password"
})
const
userToFront
:
User
|
null
=
await
dataSource
.
manager
.
findOneBy
(
User
,
{
email
:
req
.
body
.
email
})
...
...
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