sdy

add isAuthenticated middleware

import { prisma } from "../../../utils";
import { prisma, isAuthenticated } from "../../../utils";
import bcrypt from "bcryptjs";
export default {
Mutation: {
resetPassword: async (_, args) => {
if (isAuthenticated) {
const { secret, email, passwordOne, passwordTwo } = args;
const user = await prisma.user.findOne({
where: {
......@@ -18,7 +19,9 @@ export default {
} else {
if (passwordOne !== passwordTwo) {
// For check new password is right, the two things must be same.
throw new Error("the two password don't match each other, try again");
throw new Error(
"the two password don't match each other, try again"
);
} else {
await prisma.user.update({
where: {
......@@ -32,6 +35,9 @@ export default {
}
return user;
}
} else {
throw new Error("You need to login first");
}
},
},
};
......