verifyPin method

Future<void> verifyPin(
  1. String pin
)

Step 2: Verify the pin sent to the user's email. On success, stores resetToken and advances to ForgotPasswordStep.newPassword.

Implementation

Future<void> verifyPin(String pin) async {
  state = state.copyWith(isLoading: true, error: null);
  try {
    // Exchange the PIN for a reset token via the auth service.
    // The token is used in step 3 to authorise the password update.
    // TODO: wire to actual API endpoint when available (e.g. POST /auth/verify-reset-pin).
    state = state.copyWith(
      isLoading: false,
      resetToken: pin, // Replace with actual token from API response.
      step: ForgotPasswordStep.newPassword,
    );
  } catch (_) {
    state = state.copyWith(isLoading: false, error: 'Invalid or expired code.');
  }
}