fix: strong_password rule fails when the personal field contains an integer value.#1183
Open
warcooft wants to merge 1 commit intocodeigniter4:developfrom
Open
fix: strong_password rule fails when the personal field contains an integer value.#1183warcooft wants to merge 1 commit intocodeigniter4:developfrom
strong_password rule fails when the personal field contains an integer value.#1183warcooft wants to merge 1 commit intocodeigniter4:developfrom
Conversation
strtolower() Argument #1 ($string) must be of type string, int given strtolower() Argument #1 ($string) must be of type string, int given
Collaborator
|
@warcooft Thank you for submitting the PR. Could you please provide a step-by-step explanation of how to reproduce the issue? I was unable to reproduce the issue for the value public array $personalFields = [
//'f_name',
'employee_id'
];Data of Table "users":
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+-------------+
| id | username | status | status_message | active | last_active | created_at | updated_at | deleted_at | employee_id |
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+-------------+
| 6 | datamweb | | | 1 | | 2024-08-26 20:4... | 2024-08-26 20:4... | | 30303030 |
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+-------------+ |
Contributor
Author
|
Step to Reproduce make sure field $fields = [
'employee_id' => ['type' => 'TINYINT', 'default' => 1],
];Login first! then add this to your controller. public function index()
{
//login first
$data = [
'password' => '12345678Aa',
'password_confirm' => '12345678Aa',
'old_password' => 'P@ssw0rd' //change this with your password
];
if (!$this->validateData($data, $this->getValidationRules())) {
dd($this->validator->getErrors());
}
$result = auth()->check([
'email' => auth()->user()->email,
'password' => $data['old_password'],
]);
if (!$result->isOK()) {
// wrong password
dd('wrong password');
}
// Success!
$users = auth()->getProvider();
$user = auth()->user()->fill([
'password' => $data['password']
]);
$users->save($user);
}
protected function getValidationRules(): array
{
return setting('Validation.changePassword') ?? [
'password' => [
'label' => 'Auth.password',
'rules' => 'required|strong_password',
],
'password_confirm' => [
'label' => 'Auth.passwordConfirm',
'rules' => 'required|matches[password]',
],
];
}the error seems to arise from the |
strtolower() Argument #1 ($string) must be of type string, int given strong_password rule fails when the personal field contains an integer value.
Member
|
Important We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works. First, please write test code that reproduces the error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
strong_passwordrule fails when the personal field contains an integer value. so, we must convert the personal field's data type to a string. See #1171 (comment)Checklist: