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-25 23:09:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a3647b7c39c5f2db3db6d53c0a451cd8034d0e87
a3647b7c
1 parent
88b1c139
add isAuthenticated middleware
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
back/src/api/User/resetPassword/resetPassword.js
back/src/api/User/resetPassword/resetPassword.js
View file @
a3647b7
import
{
prisma
}
from
"../../../utils"
;
import
{
prisma
,
isAuthenticated
}
from
"../../../utils"
;
import
bcrypt
from
"bcryptjs"
;
export
default
{
Mutation
:
{
resetPassword
:
async
(
_
,
args
)
=>
{
if
(
isAuthenticated
)
{
const
{
secret
,
email
,
passwordOne
,
passwordTwo
}
=
args
;
const
user
=
await
prisma
.
user
.
findOne
({
where
:
{
...
...
@@ -18,7 +19,9 @@ export default {
}
else
{
if
(
passwordOne
!==
passwordTwo
)
{
// For check new password is right, the two things must be same.
throw
new
Error
(
"the two password don't match each other, try again"
);
throw
new
Error
(
"the two password don't match each other, try again"
);
}
else
{
await
prisma
.
user
.
update
({
where
:
{
...
...
@@ -32,6 +35,9 @@ export default {
}
return
user
;
}
}
else
{
throw
new
Error
(
"You need to login first"
);
}
},
},
};
...
...
Please
register
or
login
to post a comment