Password Management
Change Password
To change a user's password:
typescript
const changePasswordResult = await geinsCRM.auth.changePassword({
username: 'user@example.com',
password: 'newPassword123',
});
if (changePasswordResult?.succeeded) {
console.log('Password changed successfully');
} else {
console.error('Failed to change password');
}
Password reset
To to initiate a password reset, call the user.password.requestReset method with the user's email address. This will send an email to the user with a reset key.
typescript
const resetResult = await geinsCRM.auth.user.password.requestReset('user@example.com');
After the user has initiated the password reset, they need to submit a new password. This is done by calling the user.password.commitReset method with the reset key and the new password.
typescript
const resetResult = await geinsCRM.auth.user.password.commitReset('reset-key', 'newPassword123');