Skip to content

Commit

Permalink
Merge pull request #61 from craftcms/bugfix/permissions-adjustments
Browse files Browse the repository at this point in the history
additional permissions checks
  • Loading branch information
i-just authored Nov 27, 2024
2 parents 78c84bc + b6a4d02 commit f533465
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Unreleased

- Fixed a bug where the products index page gave impression that it was possible to sort by Link. ([#59](https://github.com/craftcms/stripe/issues/59))
- Fixed a bug where, in certain cases, it was possible to access a Subscription element in a slideout without having permission to access the Stripe plugin. ([#61](https://github.com/craftcms/stripe/pull/61))
- Fixed a bug where the “Sync from Stripe” user menu item was shown even if user didn't permission to access the Stripe plugin. ([#61](https://github.com/craftcms/stripe/pull/61))

## 1.3.0 - 2024-11-19

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ private function registerUserActions(): void
Element::EVENT_DEFINE_ACTION_MENU_ITEMS,
function(DefineMenuItemsEvent $event) {
$sender = $event->sender;
if ($email = $sender->email) {
if ($email = $sender->email && Craft::$app->getUser()->checkPermission('accessPlugin-stripe')) {
$customers = Plugin::getInstance()->getApi()->fetchAllCustomers(['email' => $email]);
if ($customers) {
$stripeIds = collect($customers)->pluck('id');
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/CustomersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace craft\stripe\controllers;

use Craft;
use craft\controllers\EditUserTrait;
use craft\elements\User;
use craft\helpers\Cp;
Expand Down Expand Up @@ -56,6 +57,7 @@ public function actionIndex(?int $userId = null): Response
'context' => 'embedded-index',
'jsSettings' => [
'criteria' => ['userId' => $user->id],
'static' => !Craft::$app->getUser()->checkPermission('editUsers'),
],
]);

Expand Down
2 changes: 1 addition & 1 deletion src/elements/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ protected static function defineDefaultCardAttributes(): array
*/
public function canView(User $user): bool
{
return true;
return parent::canView($user) || $user->can('accessPlugin-stripe');
}

/**
Expand Down

0 comments on commit f533465

Please sign in to comment.