Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-04-21 00:30:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
15e2115c6f95e50fcda28ca7eca57c43459e2ace
15e2115c
1 parent
fbd4bfb1
update login resolver codes
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
back/src/api/User/login/login.js
back/src/api/User/login/login.js
View file @
15e2115
...
...
@@ -4,24 +4,21 @@ import jwt from "jsonwebtoken";
export
default
{
Mutation
:
{
login
:
async
(
_
,
args
,
context
)
=>
{
login
:
async
(
_
,
args
)
=>
{
const
{
email
,
password
}
=
args
;
const
user
=
await
prisma
.
user
.
findOne
({
where
:
{
email
,
},
});
if
(
!
user
)
{
throw
new
Error
(
"There is no such user"
);
let
vaild
;
if
(
user
)
{
vaild
=
await
bcrypt
.
compare
(
password
,
user
.
password
);
}
const
vaild
=
await
bcrypt
.
compare
(
password
,
user
.
password
);
if
(
!
vaild
)
{
throw
new
Error
(
"Invaild Password!"
);
if
(
!
user
||
!
vaild
)
{
throw
new
Error
(
"Not vaild email or password"
);
}
const
token
=
jwt
.
sign
({
id
:
user
.
id
},
process
.
env
.
JWT_SECRET
);
return
{
token
,
user
};
},
},
...
...
Please
register
or
login
to post a comment