From 542532732f3fda0998684a95ff5c8791411505a0 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 13 Dec 2024 08:45:51 +0100 Subject: [PATCH 1/3] Fix null handling in LoginLinkRequest userAttributes Previously, the method could return `null` if `user_attributes` was not set. This update ensures it always returns an array, preventing potential issues with downstream usage. --- src/Http/Requests/LoginLinkRequest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Http/Requests/LoginLinkRequest.php b/src/Http/Requests/LoginLinkRequest.php index 29cd9f2..f068491 100644 --- a/src/Http/Requests/LoginLinkRequest.php +++ b/src/Http/Requests/LoginLinkRequest.php @@ -19,6 +19,10 @@ public function rules(): array public function userAttributes(): array { - return json_decode($this->user_attributes, true) ?? []; + if ($this->user_attributes !== null) { + return json_decode($this->user_attributes); + } + + return []; } } From ae6caface76a8daa866a3eb4152d5e219af573ac Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 13 Dec 2024 08:58:49 +0100 Subject: [PATCH 2/3] Fix JSON decoding to return associative arrays Updated the `json_decode` function to use the associative array option. This ensures consistent data format and prevents potential issues with object-based JSON decoding. --- src/Http/Requests/LoginLinkRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Requests/LoginLinkRequest.php b/src/Http/Requests/LoginLinkRequest.php index f068491..309152e 100644 --- a/src/Http/Requests/LoginLinkRequest.php +++ b/src/Http/Requests/LoginLinkRequest.php @@ -20,7 +20,7 @@ public function rules(): array public function userAttributes(): array { if ($this->user_attributes !== null) { - return json_decode($this->user_attributes); + return json_decode($this->user_attributes, true); } return []; From 08772ed33346f4a734422344c6278929f4a3f902 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 13 Dec 2024 08:58:55 +0100 Subject: [PATCH 3/3] Remove cached PHPUnit test results and update .gitignore Deleted the `.phpunit.cache/test-results` file as it is not needed in version control. Added `.phpunit.cache` to `.gitignore` to prevent similar cache files from being tracked in the future. This improves repository cleanliness and avoids unnecessary clutter. --- .gitignore | 1 + .phpunit.cache/test-results | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .phpunit.cache/test-results diff --git a/.gitignore b/.gitignore index 726b886..f2cb028 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea .php_cs .php_cs.cache +.phpunit.cache .phpunit.result.cache build composer.lock diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results deleted file mode 100644 index 77ebaf4..0000000 --- a/.phpunit.cache/test-results +++ /dev/null @@ -1 +0,0 @@ -{"version":"pest_2.34.1","defects":[],"times":{"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_a_specific_guard":0.001,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_a_custom_key":0.001,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_specific_css_classes":0,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_custom_user_attributes":0.001,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_a_custom_label":0,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_a_specific_redirect_url":0.001,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link":0.007,"P\\Tests\\LoginLinkComponentTest::__pest_evaluable_it_can_render_a_login_link_with_a_custom_email":0,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_will_not_create_a_user_if_automatic_creation_is_turned_off":0.004,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_create_a_user_with_specific_id":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_throw_an_exception_when_a_user_model_is_not_configured":0.002,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_create_and_login_a_user_on_a_specific_guard":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_throw_an_exception_when_no_user_class_can_be_determined":0.001,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_create_login_an_existing_user_with_specific_attributes":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_not_create_a_new_user_if_one_already_exists":0.062,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_login_an_existing_user_with_a_specific_email":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_not_work_in_the_wrong_environment":0.001,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_create_and_login_a_user":0.082,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_create_a_user_with_both_email_and_custom_attributes":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_create_a_user_with_specific_email":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_login_an_existing_user_with_a_specific_id":0.062,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_create_and_login_a_user_with_specific_attributes":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_can_redirect_to_a_specific_url":0.061,"P\\Tests\\LoginLinkControllerTest::__pest_evaluable_it_will_redirect_to_the_configured_route_name_by_default":0.061}} \ No newline at end of file