Showing
2 changed files
with
11 additions
and
4 deletions
1 | -import { prisma, generateSecret } from "../../../utils"; | 1 | +import { prisma, generateSecret, isAuthenticated } 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 | + if (isAuthenticated) { | ||
7 | const { phoneNumber } = args; | 8 | const { phoneNumber } = args; |
8 | const accountSid = process.env.TWILIO_SID; | 9 | const accountSid = process.env.TWILIO_SID; |
9 | const authToken = process.env.TWILIO_AUTH_TOKEN; | 10 | const authToken = process.env.TWILIO_AUTH_TOKEN; |
... | @@ -15,7 +16,10 @@ export default { | ... | @@ -15,7 +16,10 @@ export default { |
15 | to: `${phoneNumber}`, | 16 | to: `${phoneNumber}`, |
16 | from: "KhuChat", | 17 | from: "KhuChat", |
17 | }) | 18 | }) |
18 | - .then((message) => console.log(message.sid)); | 19 | + .then((message) => { |
20 | + console.log(message.sid); | ||
21 | + console.log(" --- " + message); | ||
22 | + }); | ||
19 | 23 | ||
20 | const user = await prisma.user.update({ | 24 | const user = await prisma.user.update({ |
21 | where: { | 25 | where: { |
... | @@ -25,7 +29,10 @@ export default { | ... | @@ -25,7 +29,10 @@ export default { |
25 | phoneSecret: randomWords, | 29 | phoneSecret: randomWords, |
26 | }, | 30 | }, |
27 | }); | 31 | }); |
28 | - return user; | 32 | + return user.email; |
33 | + } else { | ||
34 | + throw new Error("You need to login first"); | ||
35 | + } | ||
29 | }, | 36 | }, |
30 | }, | 37 | }, |
31 | }; | 38 | }; | ... | ... |
-
Please register or login to post a comment