feat: Implement forgotPassword mutation

This commit is contained in:
Faruk AYDIN
2023-02-18 16:54:01 +01:00
parent e4021bf830
commit 90dcbadc52
7 changed files with 70 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
import User from '../../models/user';
type Params = {
input: {
email: string;
};
};
const forgotPassword = async (_parent: unknown, params: Params) => {
const { email } = params.input;
const user = await User.query().findOne({ email });
if (!user) {
throw new Error('Email address not found!');
}
await user.generateResetPasswordToken();
// TODO: Send email with reset password link
return;
};
export default forgotPassword;