sdy

update requestEmailSecret

1 +type Mutation {
2 + requestEmailSecret(email: String!): Boolean!
3 +}
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 +};