or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication-lifecycle.mddevice-management.mdindex.mdmulti-factor-authentication.mdoauth-social-authentication.mdpassword-management.mdserver-side-apis.mdsession-management.mduser-management.mdwebauthn-credentials.md
tile.json

password-management.mddocs/

Password Management

Password reset, confirmation, and update operations for user account security.

Reset Password

Initiate a password reset flow for a user.

function resetPassword(input: ResetPasswordInput): Promise<ResetPasswordOutput>;

interface ResetPasswordInput {
  username: string;
  options?: {
    clientMetadata?: Record<string, string>;
  };
}

interface ResetPasswordOutput {
  nextStep: {
    resetPasswordStep: 'CONFIRM_RESET_PASSWORD_WITH_CODE' | 'DONE';
    codeDeliveryDetails?: CodeDeliveryDetails;
  };
}

Usage Example

import { resetPassword } from "@aws-amplify/auth";

const { nextStep } = await resetPassword({
  username: "user@example.com"
});

if (nextStep.resetPasswordStep === 'CONFIRM_RESET_PASSWORD_WITH_CODE') {
  console.log(`Reset code sent to: ${nextStep.codeDeliveryDetails?.destination}`);
}

Confirm Reset Password

Complete the password reset process using the verification code.

function confirmResetPassword(input: ConfirmResetPasswordInput): Promise<void>;

interface ConfirmResetPasswordInput {
  username: string;
  confirmationCode: string;
  newPassword: string;
  options?: {
    clientMetadata?: Record<string, string>;
  };
}

Usage Example

import { confirmResetPassword } from "@aws-amplify/auth";

await confirmResetPassword({
  username: "user@example.com",
  confirmationCode: "123456",
  newPassword: "NewSecurePassword123!"
});

console.log("Password reset successfully");

Update Password

Update the password for a signed-in user.

function updatePassword(input: UpdatePasswordInput): Promise<void>;

interface UpdatePasswordInput {
  oldPassword: string;
  newPassword: string;
}

Usage Example

import { updatePassword } from "@aws-amplify/auth";

await updatePassword({
  oldPassword: "CurrentPassword123!",
  newPassword: "NewSecurePassword456!"
});

console.log("Password updated successfully");

Password Requirements

When setting passwords, ensure they meet your Cognito User Pool password policy requirements. Common requirements include:

  • Minimum 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one number
  • At least one special character

Error Handling

Password operations may throw various errors:

import { resetPassword, AuthError } from "@aws-amplify/auth";

try {
  await resetPassword({ username: "user@example.com" });
} catch (error) {
  if (error instanceof AuthError) {
    switch (error.name) {
      case 'UserNotFoundException':
        console.log('User not found');
        break;
      case 'LimitExceededException':
        console.log('Too many requests, please try again later');
        break;
      case 'InvalidParameterException':
        console.log('Invalid username format');
        break;
      default:
        console.log('Password reset failed:', error.message);
    }
  }
}