sdy

update createAccount resolver, typedefs

...@@ -3,6 +3,7 @@ type Mutation { ...@@ -3,6 +3,7 @@ type Mutation {
3 username: String! 3 username: String!
4 email: String! 4 email: String!
5 password: String! 5 password: String!
6 + password2: String!
6 bio: String 7 bio: String
7 avatarUrl: String 8 avatarUrl: String
8 phoneNum: String! 9 phoneNum: String!
......
...@@ -4,13 +4,24 @@ import bcrypt from "bcryptjs"; ...@@ -4,13 +4,24 @@ import bcrypt from "bcryptjs";
4 export default { 4 export default {
5 Mutation: { 5 Mutation: {
6 createAccount: async (_, args) => { 6 createAccount: async (_, args) => {
7 - const { name, password, email, bio, avatarUrl, phoneNum } = args; 7 + const {
8 + username,
9 + password,
10 + password2,
11 + email,
12 + bio,
13 + avatarUrl,
14 + phoneNum,
15 + } = args;
16 + if (password !== password2) {
17 + throw new Error("two password aren't same each other");
18 + }
8 const encryptPw = await bcrypt.hash(password, 10); 19 const encryptPw = await bcrypt.hash(password, 10);
9 // TODO: Find user's country code and change new phone number value 20 // TODO: Find user's country code and change new phone number value
10 const newPhoneNumber = await changePhoneNumber(phoneNum, "+82"); 21 const newPhoneNumber = await changePhoneNumber(phoneNum, "+82");
11 const user = await prisma.user.create({ 22 const user = await prisma.user.create({
12 data: { 23 data: {
13 - name, 24 + username,
14 email, 25 email,
15 bio, 26 bio,
16 avatarUrl, 27 avatarUrl,
......