-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: strong_password
rule fails when the personal field contains an integer value.
#1183
base: develop
Are you sure you want to change the base?
fix: strong_password
rule fails when the personal field contains an integer value.
#1183
Conversation
strtolower()
Argument #1 ($string) must be of type string, int given strtolower()
Argument #1 ($string) must be of type string, int given
@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 |
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+-------------+ |
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.
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. |
Description
strong_password
rule 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: