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-26 15:23:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8923f8892ed9f8668ae15b28c7f703f7c3690c05
8923f889
1 parent
56440749
rename secret to emailSecret
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
11 deletions
back/src/api/User/resetPassword/resetPassword.graphql
back/src/api/User/resetPassword/resetPassword.js
back/src/api/User/resetPassword/resetPassword.graphql
View file @
8923f88
type Mutation {
resetPassword(
s
ecret: String!
emailS
ecret: String!
email: String!
passwordOne: String!
passwordTwo: String!
...
...
back/src/api/User/resetPassword/resetPassword.js
View file @
8923f88
...
...
@@ -3,25 +3,23 @@ import bcrypt from "bcryptjs";
export
default
{
Mutation
:
{
resetPassword
:
async
(
_
,
args
)
=>
{
i
f
(
isAuthenticated
)
{
const
{
s
ecret
,
email
,
passwordOne
,
passwordTwo
}
=
args
;
resetPassword
:
async
(
_
,
args
,
{
request
}
)
=>
{
i
sAuthenticated
(
request
);
const
{
emailS
ecret
,
email
,
passwordOne
,
passwordTwo
}
=
args
;
const
user
=
await
prisma
.
user
.
findOne
({
where
:
{
email
,
},
});
const
encryptSecret
=
await
bcrypt
.
hash
(
user
.
emailSecret
,
10
);
if
(
encryptSecret
!==
s
ecret
)
{
if
(
encryptSecret
!==
emailS
ecret
)
{
throw
new
Error
(
"not vaild secret value!, input another value or resend email"
);
}
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
:
{
...
...
@@ -35,9 +33,6 @@ export default {
}
return
user
;
}
}
else
{
throw
new
Error
(
"You need to login first"
);
}
},
},
};
...
...
Please
register
or
login
to post a comment