feat: Implement forgotPassword mutation
This commit is contained in:
@@ -14,6 +14,7 @@ import updateStep from './mutations/update-step';
|
||||
import deleteStep from './mutations/delete-step';
|
||||
import createUser from './mutations/create-user.ee';
|
||||
import updateUser from './mutations/update-user';
|
||||
import forgotPassword from './mutations/forgot-password.ee';
|
||||
import login from './mutations/login';
|
||||
|
||||
const mutationResolvers = {
|
||||
@@ -33,6 +34,7 @@ const mutationResolvers = {
|
||||
deleteStep,
|
||||
createUser,
|
||||
updateUser,
|
||||
forgotPassword,
|
||||
login,
|
||||
};
|
||||
|
||||
|
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;
|
@@ -50,6 +50,7 @@ type Mutation {
|
||||
deleteStep(input: DeleteStepInput): Step
|
||||
createUser(input: CreateUserInput): User
|
||||
updateUser(input: UpdateUserInput): User
|
||||
forgotPassword(input: ForgotPasswordInput): Boolean
|
||||
login(input: LoginInput): Auth
|
||||
}
|
||||
|
||||
@@ -302,8 +303,8 @@ input DeleteStepInput {
|
||||
}
|
||||
|
||||
input CreateUserInput {
|
||||
email: String
|
||||
password: String
|
||||
email: String!
|
||||
password: String!
|
||||
}
|
||||
|
||||
input UpdateUserInput {
|
||||
@@ -311,6 +312,10 @@ input UpdateUserInput {
|
||||
password: String
|
||||
}
|
||||
|
||||
input ForgotPasswordInput {
|
||||
email: String
|
||||
}
|
||||
|
||||
input LoginInput {
|
||||
email: String!
|
||||
password: String!
|
||||
|
Reference in New Issue
Block a user