Skip to content

TypeScript API / @laikacms/server/oauth2 / resetPassword

Function: resetPassword() ​

ts
function resetPassword(
   token, 
   newPassword, 
   config
): Promise<{
  error?: string;
  success: boolean;
  userId?: string;
}>;

Reset a user's password using a valid reset token.

Parameters ​

ParameterTypeDescription
tokenstringThe reset token from the email link
newPasswordstringThe new password to set
configPasswordResetConfigPassword reset configuration

Returns ​

Promise<{ error?: string; success: boolean; userId?: string; }>

Result indicating success or failure

Example ​

typescript
import { resetPassword } from '@laikacms/server/oauth2';
import { hashPassword } from '@laikacms/server/oauth2';

const result = await resetPassword(
  'abc123token',
  'newSecurePassword123',
  config,
  hashPassword
);

if (result.success) {
  console.log('Password reset successfully');
}

Released under the MIT License.