sdy

add bcrypt

1 import { prisma, generateSecret, sendSecretMail } from "../../../utils"; 1 import { prisma, generateSecret, sendSecretMail } from "../../../utils";
2 +import bcrypt from "bcryptjs";
2 3
3 export default { 4 export default {
4 Mutation: { 5 Mutation: {
5 requestEmailSecret: async (_, args) => { 6 requestEmailSecret: async (_, args) => {
6 const { email } = args; 7 const { email } = args;
7 const emailSecret = generateSecret(); 8 const emailSecret = generateSecret();
9 + const encryptSecret = await bcrypt.hash(emailSecret, 10);
8 try { 10 try {
9 await sendSecretMail(email, emailSecret); 11 await sendSecretMail(email, emailSecret);
10 await prisma.user.update({ 12 await prisma.user.update({
...@@ -12,7 +14,7 @@ export default { ...@@ -12,7 +14,7 @@ export default {
12 email, 14 email,
13 }, 15 },
14 data: { 16 data: {
15 - emailSecret, 17 + emailSecret: encryptSecret,
16 }, 18 },
17 }); 19 });
18 return true; 20 return true;
......