WiFiManager- unable to handle a bad password?

Thanks, jura.

I have integrated the WiFiManager into my code and it seems to work with a couple of issues that I need to work on.

First, I am working from the OnDemandConfigPortal example. When a GPIO pin is pulled low, the configureWiFi() funcion is called.

// =========== configureWiFi() ===========
void configureWiFi() {

  // Clear the connected flag so that the next time in loop we will see the credentials
  WiFiConnected = false;

  //Make an instance of WiFiManager
  WiFiManager wifiManager;

  //reset settings - for testing
  //wifiManager.resetSettings();
  WiFi.disconnect();                        // Forget prior credentials
  delay(1000);
  Serial.println(F("Forgot credentials."));

  //sets timeout (seconds) until configuration portal gets turned off
  //useful to make it all retry or go to sleep
  //wifiManager.setTimeout(120);

  //WITHOUT THIS THE AP DOES NOT SEEM TO WORK PROPERLY WITH SDK 1.5 , update to at least 1.5.1
  //WiFi.mode(WIFI_STA);

  // start the Access Point
  if (!wifiManager.startConfigPortal("Telephone")) {
    Serial.println("**Failed to connect and reached timeout**");
    delay(3000);
    ESP.reset();                  //reset and try again, or maybe put it to deep sleep
    delay(5000);
  }

  //if you get here you have connected to the WiFi
  Serial.println("WiFi connected...yeey :)");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

I added the WiFi.disconnect because no matter what I entered from the AP site, the WiFiManager used the stored WiFi credentials. (WiFiDisconnect() is supposed to make the ESP forget it's stored credentials.)

Second, my bigger problem, is how to handle a bad password? If I enter the WiFi credentials into the AP web page, and if the password is bad, WiFiManager just stops.

Any tips would be appreciated.