Showing
2 changed files
with
28 additions
and
0 deletions
| 1 | +import { prisma, generateSecret, sendSecretMail } from "../../../utils"; | ||
| 2 | + | ||
| 3 | +export default { | ||
| 4 | + Mutation: { | ||
| 5 | + requestEmailSecret: async (_, args) => { | ||
| 6 | + const { email } = args; | ||
| 7 | + const emailSecret = generateSecret(); | ||
| 8 | + try { | ||
| 9 | + await sendSecretMail(email, emailSecret); | ||
| 10 | + await prisma.user.update({ | ||
| 11 | + where: { | ||
| 12 | + email, | ||
| 13 | + }, | ||
| 14 | + data: { | ||
| 15 | + emailSecret, | ||
| 16 | + }, | ||
| 17 | + }); | ||
| 18 | + return true; | ||
| 19 | + } catch (error) { | ||
| 20 | + console.log(error); | ||
| 21 | + return false; | ||
| 22 | + } | ||
| 23 | + }, | ||
| 24 | + }, | ||
| 25 | +}; |
-
Please register or login to post a comment