From 6485a2958e5ace04a3a88d865b48842bd36b2f04 Mon Sep 17 00:00:00 2001 From: i-just Date: Mon, 6 Jan 2025 08:10:38 +0000 Subject: [PATCH 1/3] move key and permission checks inside the event --- src/Plugin.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 17dce99..70dce08 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -574,14 +574,14 @@ function(RegisterConditionRulesEvent $event) { private function registerUserActions(): void { - if ( - !empty(Plugin::getInstance()->getApi()->getApiKey()) && - Craft::$app->getUser()->checkPermission('accessPlugin-stripe') - ) { - Event::on( - User::class, - Element::EVENT_DEFINE_ACTION_MENU_ITEMS, - function(DefineMenuItemsEvent $event) { + Event::on( + User::class, + Element::EVENT_DEFINE_ACTION_MENU_ITEMS, + function(DefineMenuItemsEvent $event) { + if ( + !empty(Plugin::getInstance()->getApi()->getApiKey()) && + Craft::$app->getUser()->checkPermission('accessPlugin-stripe') + ) { $sender = $event->sender; if ($email = $sender->email) { $customers = Plugin::getInstance()->getApi()->fetchAllCustomers(['email' => $email]); @@ -598,8 +598,8 @@ function(DefineMenuItemsEvent $event) { } } } - ); - } + } + ); } /** From f61c92cac762ebd9e22a5d632afdb04d211c5c3a Mon Sep 17 00:00:00 2001 From: i-just Date: Tue, 7 Jan 2025 07:53:10 +0000 Subject: [PATCH 2/3] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75d5e64..ccda52b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Release Notes for Stripe +## Unreleased +- Fixed an error where the plugin could attempt to check User permissions before Craft was fully initialized. ([#71](https://github.com/craftcms/stripe/issues/71)) + ## 1.3.2 - 2024-12-11 - Fixed an error that occurred on Edit Entry screens if Stripe wasn’t configured with an API key. ([#66](https://github.com/craftcms/stripe/pull/66)) From fcb919eb249b846549cb060ea251d7661bab41df Mon Sep 17 00:00:00 2001 From: i-just Date: Tue, 7 Jan 2025 07:57:41 +0000 Subject: [PATCH 3/3] prettier --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccda52b..1261471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Release Notes for Stripe ## Unreleased -- Fixed an error where the plugin could attempt to check User permissions before Craft was fully initialized. ([#71](https://github.com/craftcms/stripe/issues/71)) + +- Fixed an error where the plugin could attempt to check User permissions before Craft was fully initialized. ([#71](https://github.com/craftcms/stripe/issues/71)) ## 1.3.2 - 2024-12-11