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-08-31 22:55:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a9a898301625b0dc4d18f7bbd8c529784baebd4e
a9a89830
1 parent
1681cbb0
remove unnecessary fields
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
10 deletions
back/src/api/User/createAccount/createAccount.graphql
back/src/api/User/createAccount/createAccount.js
back/src/api/User/createAccount/createAccount.graphql
View file @
a9a8983
...
...
@@ -3,8 +3,5 @@ type Mutation {
username: String!
email: String!
password: String!
phoneNum: String!
bio: String
avatarUrl: String
): AuthPayload!
}
...
...
back/src/api/User/createAccount/createAccount.js
View file @
a9a8983
import
{
prisma
,
generateToken
,
changePhoneNumber
}
from
"../../../utils"
;
import
{
prisma
,
generateToken
}
from
"../../../utils"
;
import
bcrypt
from
"bcryptjs"
;
export
default
{
Mutation
:
{
createAccount
:
async
(
_
,
args
)
=>
{
const
{
username
,
password
,
email
,
phoneNum
,
bio
,
avatarUrl
}
=
args
;
const
{
username
,
password
,
email
}
=
args
;
const
encryptPw
=
await
bcrypt
.
hash
(
password
,
10
);
// TODO: Find user's country code and change new phone number value
const
newPhoneNumber
=
await
changePhoneNumber
(
phoneNum
,
"+82"
);
const
user
=
await
prisma
.
user
.
create
({
data
:
{
username
,
email
,
password
:
encryptPw
,
phoneNum
:
newPhoneNumber
,
bio
,
avatarUrl
,
},
});
const
token
=
generateToken
(
user
.
id
);
...
...
Please
register
or
login
to post a comment