mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-22 16:02:54 +03:00
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.
This commit is contained in:
parent
da98768cd0
commit
c50c545d98
1 changed files with 6 additions and 5 deletions
|
@ -68,7 +68,7 @@ class Customers_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function exists($customer)
|
public function exists($customer)
|
||||||
{
|
{
|
||||||
if ( ! isset($customer['email']))
|
if (empty($customer['email']))
|
||||||
{
|
{
|
||||||
throw new Exception('Customer\'s email is not provided.');
|
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)
|
public function find_record_id($customer)
|
||||||
{
|
{
|
||||||
if ( ! isset($customer['email']))
|
if (empty($customer['email']))
|
||||||
{
|
{
|
||||||
throw new Exception('Customer\'s email was not provided: '
|
throw new Exception('Customer\'s email was not provided: '
|
||||||
. print_r($customer, TRUE));
|
. print_r($customer, TRUE));
|
||||||
|
@ -212,9 +212,10 @@ class Customers_Model extends CI_Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if ( ! isset($customer['last_name'])
|
if (empty($customer['first_name'])
|
||||||
|| ! isset($customer['email'])
|
|| empty($customer['last_name'])
|
||||||
|| ! isset($customer['phone_number']))
|
|| empty($customer['email'])
|
||||||
|
|| empty($customer['phone_number']))
|
||||||
{
|
{
|
||||||
throw new Exception('Not all required fields are provided: '
|
throw new Exception('Not all required fields are provided: '
|
||||||
. print_r($customer, TRUE));
|
. print_r($customer, TRUE));
|
||||||
|
|
Loading…
Reference in a new issue