Showing
2 changed files
with
11 additions
and
2 deletions
1 | -import { prisma, generateToken } from "../../../utils"; | 1 | +import { prisma, generateToken, changePhoneNumber } from "../../../utils"; |
2 | import bcrypt from "bcryptjs"; | 2 | import bcrypt from "bcryptjs"; |
3 | 3 | ||
4 | export default { | 4 | export default { |
... | @@ -6,6 +6,8 @@ export default { | ... | @@ -6,6 +6,8 @@ export default { |
6 | createAccount: async (_, args) => { | 6 | createAccount: async (_, args) => { |
7 | const { name, password, email, bio, avatarUrl, phoneNum } = args; | 7 | const { name, password, email, bio, avatarUrl, phoneNum } = args; |
8 | const encryptPw = await bcrypt.hash(password, 10); | 8 | const encryptPw = await bcrypt.hash(password, 10); |
9 | + // TODO: Find user's country code and change new phone number value | ||
10 | + const newPhoneNumber = await changePhoneNumber(phoneNum, "+82"); | ||
9 | const user = await prisma.user.create({ | 11 | const user = await prisma.user.create({ |
10 | data: { | 12 | data: { |
11 | name, | 13 | name, |
... | @@ -13,7 +15,7 @@ export default { | ... | @@ -13,7 +15,7 @@ export default { |
13 | bio, | 15 | bio, |
14 | avatarUrl, | 16 | avatarUrl, |
15 | password: encryptPw, | 17 | password: encryptPw, |
16 | - phoneNum, | 18 | + phoneNum: newPhoneNumber, |
17 | }, | 19 | }, |
18 | }); | 20 | }); |
19 | const token = generateToken(user.id); | 21 | const token = generateToken(user.id); | ... | ... |
... | @@ -23,6 +23,13 @@ export const isAuthenticated = (request) => { | ... | @@ -23,6 +23,13 @@ export const isAuthenticated = (request) => { |
23 | return; | 23 | return; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | +export const changePhoneNumber = (phoneNum, locationNum) => { | ||
27 | + var leftStr = locationNum; | ||
28 | + var rightStr = phoneNum.slice(1, phoneNum.length()); | ||
29 | + var newStr = leftStr + rightStr; | ||
30 | + return newStr; | ||
31 | +}; | ||
32 | + | ||
26 | export const generateSecret = () => { | 33 | export const generateSecret = () => { |
27 | const randomNumber = Math.floor(Math.random() * adjectives.length); | 34 | const randomNumber = Math.floor(Math.random() * adjectives.length); |
28 | return `${adjectives[randomNumber]} ${nouns[randomNumber]}`; | 35 | return `${adjectives[randomNumber]} ${nouns[randomNumber]}`; | ... | ... |
-
Please register or login to post a comment