From ac3ad3d23bde3fceacf287237a22b3ee5f02d450 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 26 Feb 2015 15:33:35 -0500 Subject: [PATCH] Prevent overwriting the database if it already exists --- airtime_mvc/application/common/ProvisioningHelper.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/common/ProvisioningHelper.php b/airtime_mvc/application/common/ProvisioningHelper.php index 9804e7d6e..9cc69ab5e 100644 --- a/airtime_mvc/application/common/ProvisioningHelper.php +++ b/airtime_mvc/application/common/ProvisioningHelper.php @@ -36,10 +36,13 @@ class ProvisioningHelper $this->parsePostParams(); //For security, the Airtime Pro provisioning system creates the database for the user. - // $this->setNewDatabaseConnection(); - //if ($this->checkDatabaseExists()) { - // throw new Exception("ERROR: Airtime database already exists"); - //} + $this->setNewDatabaseConnection(); + + //We really want to do this check because all the Propel-generated SQL starts with "DROP TABLE IF EXISTS". + //If we don't check, then a second call to this API endpoint would wipe all the tables! + if ($this->checkDatabaseExists()) { + throw new Exception("ERROR: Airtime database already exists"); + } //$this->createDatabase(); //All we need to do is create the database tables.