'Amplify delete user's own account after OTP verification

Is there a way to delete a user's own account only after OTP verification in order to confirm his identity? The OTP can be sent to either email or mobile number depending on what they used for account creation. How can I configure this OTP flow?

// delete user

async function deleteUser() {
  try {
    const result = await Auth.deleteUser();
    console.log(result);
  } catch (error) {
    console.log('Error deleting user', error);
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source