mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-18 13:28:32 -04:00
Fix username verification on insert/update (#3239)
This commit is contained in:
@@ -60,6 +60,7 @@ class Employees extends Persons
|
||||
$person_info->$property = $this->xss_clean($value);
|
||||
}
|
||||
$data['person_info'] = $person_info;
|
||||
$data['employee_id'] = $employee_id;
|
||||
|
||||
$modules = array();
|
||||
foreach($this->Module->get_all_modules()->result() as $module)
|
||||
@@ -191,9 +192,9 @@ class Employees extends Persons
|
||||
}
|
||||
}
|
||||
|
||||
public function check_username()
|
||||
public function check_username($employee_id)
|
||||
{
|
||||
$exists = $this->Employee->username_exists($this->input->get('username'));
|
||||
$exists = $this->Employee->username_exists($employee_id, $this->input->get('username'));
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@ class Employee extends Person
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
public function username_exists($username)
|
||||
public function username_exists($employee_id, $username)
|
||||
{
|
||||
$this->db->from('employees');
|
||||
$this->db->where('employees.username', $username);
|
||||
$this->db->where('employees.person_id <>', $employee_id);
|
||||
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
@@ -209,17 +209,10 @@ $(document).ready(function()
|
||||
last_name: 'required',
|
||||
username:
|
||||
{
|
||||
<?php
|
||||
if($person_info->person_id == "")
|
||||
{
|
||||
?>
|
||||
remote: '<?php echo site_url("$controller_name/check_username")?>',
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
required: true,
|
||||
minlength: 5
|
||||
|
||||
required: true,
|
||||
minlength: 5,
|
||||
remote: '<?php echo site_url("$controller_name/check_username/$employee_id")?>'
|
||||
},
|
||||
password:
|
||||
{
|
||||
@@ -270,4 +263,4 @@ $(document).ready(function()
|
||||
}
|
||||
}, form_support.error));
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user