sdy

update findEmail

1 -import { prisma, isAuthenticated } from "../../../utils"; 1 +import { prisma, isAuthenticated, changePhoneNumber } from "../../../utils";
2 import twilio from "twilio"; 2 import twilio from "twilio";
3 3
4 export default { 4 export default {
5 Query: { 5 Query: {
6 findEmail: async (_, args) => { 6 findEmail: async (_, args) => {
7 const { phoneNum } = args; 7 const { phoneNum } = args;
8 + const changeNum = await changePhoneNumber(phoneNum, "+82");
8 const user = await prisma.user.findOne({ 9 const user = await prisma.user.findOne({
9 where: { 10 where: {
10 - phoneNum, 11 + phoneNum: changeNum,
11 }, 12 },
12 }); 13 });
13 if (user && isAuthenticated) { 14 if (user && isAuthenticated) {
...@@ -18,7 +19,7 @@ export default { ...@@ -18,7 +19,7 @@ export default {
18 client.messages 19 client.messages
19 .create({ 20 .create({
20 body: `Your Email is : ${user.email}`, 21 body: `Your Email is : ${user.email}`,
21 - to: `${phoneNum}`, 22 + to: `${changeNum}`,
22 from: `${twilioPhone}`, 23 from: `${twilioPhone}`,
23 }) 24 })
24 .then((message) => { 25 .then((message) => {
......