Skip to main content
Version: Next 🚧

Change Password

The Change Password module (v2 API) provides functions to change a user's password and to request a password reset by email.

Types​

ChangePasswordResponse​

type ChangePasswordResponse = {
success: boolean;
message?: string;
};
PropertyTypeRequiredDescription
successboolean✓Whether the password change succeeded
messagestringOptional message from the server

PasswordResetEmailResponse​

type PasswordResetEmailResponse = {
email?: string;
passwordResetTokenExpiry?: string;
};
PropertyTypeRequiredDescription
emailstringThe email address to which the reset link was sent
passwordResetTokenExpirystringExpiry date/time of the reset token

Functions​

fetchChangePassword()​

Changes the current user's password.

info

Throws an UnauthorizedError (401) if the current password is invalid or the user is not authorized.

Parameters

ParameterTypeRequiredDescription
newPasswordstring✓The new password to set
currentPasswordstringThe current password (required by some backends)

Returns Promise<ChangePasswordResponse> — result indicating success or failure.

Example

change-password.ts
import { fetchChangePassword } from '@sinequa/atomic';

const result = await fetchChangePassword('newSecureP@ss', 'oldP@ss');
if (result.success) {
console.log('Password changed successfully');
}

fetchSendPasswordResetEmail()​

Sends a password reset email for the given user. The reset link redirects to /login?mode=changepassword.

Parameters

ParameterTypeRequiredDescription
userNamestring✓The username for which the reset email should be sent

Returns Promise<PasswordResetEmailResponse> — contains the target email and token expiry.

Example

send-reset-email.ts
import { fetchSendPasswordResetEmail } from '@sinequa/atomic';

const response = await fetchSendPasswordResetEmail('john.doe');
console.log('Reset email sent to:', response.email);