From c50c545d9847404f34bd5d81a4352a9c3af9b2c5 Mon Sep 17 00:00:00 2001 From: DiGitHubCap <905317+DiGitHubCap@users.noreply.github.com> Date: Sat, 27 Oct 2018 21:33:22 -0400 Subject: [PATCH] Fix appointment required fields validation We should be using empty to check the fields instead of isset. Otherwise, appointments may be booked with empty fields if these are not properly validated client-side for some reason, since they will be empty strings. Also, we should check first_name. --- src/application/models/Customers_model.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/application/models/Customers_model.php b/src/application/models/Customers_model.php index b949df60..d146da6f 100644 --- a/src/application/models/Customers_model.php +++ b/src/application/models/Customers_model.php @@ -68,7 +68,7 @@ class Customers_Model extends CI_Model { */ public function exists($customer) { - if ( ! isset($customer['email'])) + if (empty($customer['email'])) { throw new Exception('Customer\'s email is not provided.'); } @@ -163,7 +163,7 @@ class Customers_Model extends CI_Model { */ public function find_record_id($customer) { - if ( ! isset($customer['email'])) + if (empty($customer['email'])) { throw new Exception('Customer\'s email was not provided: ' . print_r($customer, TRUE)); @@ -212,9 +212,10 @@ class Customers_Model extends CI_Model { } } // Validate required fields - if ( ! isset($customer['last_name']) - || ! isset($customer['email']) - || ! isset($customer['phone_number'])) + if (empty($customer['first_name']) + || empty($customer['last_name']) + || empty($customer['email']) + || empty($customer['phone_number'])) { throw new Exception('Not all required fields are provided: ' . print_r($customer, TRUE));