feat: refactor reset password mutation with the REST API endpoint
This commit is contained in:
@@ -32,7 +32,6 @@ import verifyConnection from './mutations/verify-connection.js';
|
||||
// Converted mutations
|
||||
import deleteUser from './mutations/delete-user.ee.js';
|
||||
import login from './mutations/login.js';
|
||||
import resetPassword from './mutations/reset-password.ee.js';
|
||||
|
||||
const mutationResolvers = {
|
||||
createAppAuthClient,
|
||||
@@ -54,7 +53,6 @@ const mutationResolvers = {
|
||||
login,
|
||||
registerUser,
|
||||
resetConnection,
|
||||
resetPassword,
|
||||
updateAppAuthClient,
|
||||
updateAppConfig,
|
||||
updateConfig,
|
||||
|
@@ -1,23 +0,0 @@
|
||||
import User from '../../models/user.js';
|
||||
|
||||
const resetPassword = async (_parent, params) => {
|
||||
const { token, password } = params.input;
|
||||
|
||||
if (!token) {
|
||||
throw new Error('Reset password token is required!');
|
||||
}
|
||||
|
||||
const user = await User.query().findOne({ reset_password_token: token });
|
||||
|
||||
if (!user || !user.isResetPasswordTokenValid()) {
|
||||
throw new Error(
|
||||
'Reset password link is not valid or expired. Try generating a new link.'
|
||||
);
|
||||
}
|
||||
|
||||
await user.resetPassword(password);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default resetPassword;
|
@@ -21,7 +21,6 @@ type Mutation {
|
||||
login(input: LoginInput): Auth
|
||||
registerUser(input: RegisterUserInput): User
|
||||
resetConnection(input: ResetConnectionInput): Connection
|
||||
resetPassword(input: ResetPasswordInput): Boolean
|
||||
updateAppAuthClient(input: UpdateAppAuthClientInput): AppAuthClient
|
||||
updateAppConfig(input: UpdateAppConfigInput): AppConfig
|
||||
updateConfig(input: JSONObject): JSONObject
|
||||
@@ -404,11 +403,6 @@ input UpdateCurrentUserInput {
|
||||
fullName: String
|
||||
}
|
||||
|
||||
input ResetPasswordInput {
|
||||
token: String!
|
||||
password: String!
|
||||
}
|
||||
|
||||
input LoginInput {
|
||||
email: String!
|
||||
password: String!
|
||||
|
@@ -55,7 +55,6 @@ export const authenticationRules = {
|
||||
'*': isAuthenticatedRule,
|
||||
login: allow,
|
||||
registerUser: allow,
|
||||
resetPassword: allow,
|
||||
},
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user