From 30c55a4666c9f34ca8029c95ba81a152873b4fc2 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 30 Nov 2022 11:53:45 +0100 Subject: [PATCH] Correct the validate username method --- application/models/Admins_model.php | 8 +++++++- application/models/Providers_model.php | 8 +++++++- application/models/Secretaries_model.php | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index 4ddb4d24..f1357330 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -178,7 +178,13 @@ class Admins_model extends EA_Model { $this->db->where('id_users !=', $admin_id); } - return $this->db->get_where('user_settings', ['username' => $username, 'delete_datetime' => NULL])->num_rows() === 0; + return $this + ->db + ->from('users') + ->join('user_settings', 'user_settings.id_users = users.id', 'inner') + ->where(['username' => $username, 'delete_datetime' => NULL]) + ->get() + ->num_rows() === 0; } /** diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 6bcf1862..c10e3d61 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -193,7 +193,13 @@ class Providers_model extends EA_Model { $this->db->where('id_users !=', $provider_id); } - return $this->db->get_where('user_settings', ['username' => $username, 'delete_datetime' => NULL])->num_rows() === 0; + return $this + ->db + ->from('users') + ->join('user_settings', 'user_settings.id_users = users.id', 'inner') + ->where(['username' => $username, 'delete_datetime' => NULL]) + ->get() + ->num_rows() === 0; } /** diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index d5eb8a8e..179f268a 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -191,7 +191,13 @@ class Secretaries_model extends EA_Model { $this->db->where('id_users !=', $secretary_id); } - return $this->db->get_where('user_settings', ['username' => $username, 'delete_datetime' => NULL])->num_rows() === 0; + return $this + ->db + ->from('users') + ->join('user_settings', 'user_settings.id_users = users.id', 'inner') + ->where(['username' => $username, 'delete_datetime' => NULL]) + ->get() + ->num_rows() === 0; } /**