feat: Implement forgotPassword mutation
This commit is contained in:
24
packages/backend/src/graphql/mutations/forgot-password.ee.ts
Normal file
24
packages/backend/src/graphql/mutations/forgot-password.ee.ts
Normal 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;
|
Reference in New Issue
Block a user