requestEmailSecret.js
558 Bytes
import { prisma, generateSecret, sendSecretMail } from "../../../utils";
export default {
Mutation: {
requestEmailSecret: async (_, args) => {
const { email } = args;
const emailSecret = generateSecret();
try {
await sendSecretMail(email, emailSecret);
await prisma.user.update({
where: {
email,
},
data: {
emailSecret,
},
});
return true;
} catch (error) {
console.log(error);
return false;
}
},
},
};