diff --git a/application/Models/Aauth/UserModel.php b/application/Models/Aauth/UserModel.php index 1d56f25..63ccd86 100644 --- a/application/Models/Aauth/UserModel.php +++ b/application/Models/Aauth/UserModel.php @@ -98,8 +98,8 @@ class UserModel extends Model $this->table = $this->config->dbTableUsers; $this->DBGroup = $this->config->dbProfile; - $this->validationRules['email'] = 'required_with[password]|valid_email|is_unique[' . $this->table . '.email,id,{id}]'; - $this->validationRules['password'] = 'required_with[email]|min_length[' . $this->config->passwordMin . ']|max_length[' . $this->config->passwordMax . ']'; + $this->validationRules['email'] = 'required|valid_email|is_unique[' . $this->table . '.email,id,{id}]'; + $this->validationRules['password'] = 'required|min_length[' . $this->config->passwordMin . ']|max_length[' . $this->config->passwordMax . ']'; $this->validationRules['username'] = 'if_exist|is_unique[' . $this->table . '.username,id,{id}]|regex_match[/' . $this->config->userRegexPattern . '/]'; $this->validationMessages = [ @@ -122,14 +122,24 @@ class UserModel extends Model if ($this->config->loginUseUsername) { - $this->validationRules['email'] = 'required_with[username,password]|valid_email|is_unique[' . $this->table . '.email,id,{id}]'; - $this->validationRules['password'] = 'required_with[email,username]|min_length[' . $this->config->passwordMin . ']|max_length[' . $this->config->passwordMax . ']'; - $this->validationRules['username'] = 'required_with[email,password]|is_unique[' . $this->table . '.username,id,{id}]|regex_match[/' . $this->config->userRegexPattern . '/]'; + $this->validationRules['username'] = 'required|is_unique[' . $this->table . '.username,id,{id}]|regex_match[/' . $this->config->userRegexPattern . '/]'; $this->validationMessages['username']['required'] = lang('Aauth.requiredUsername'); } } + /** + * Update + * + */ + public function update($id = null, $data = null) + { + $this->validationRules['email'] = 'if_exist|valid_email|is_unique[' . $this->table . '.email,id,{id}]'; + $this->validationRules['password'] = 'if_exist|min_length[' . $this->config->passwordMin . ']|max_length[' . $this->config->passwordMax . ']'; + $this->validationRules['username'] = 'if_exist|is_unique[' . $this->table . '.username,id,{id}]|regex_match[/' . $this->config->userRegexPattern . '/]'; + + parent::update($id, $data); + } /** * Update last login by User ID *