Skip to content

Commit

Permalink
Fix edit contact permission bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed May 12, 2023
1 parent 6f8c4e5 commit 8ff218a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Campaign

## 2.6.2 - 2023-05-12
### Fixed
- Fixed a bug in which non-admin users were not alloyed to edit contacts even with the correct permissions granted ([#378](https://github.com/putyourlightson/craft-campaign/issues/378)).

## 2.6.1 - 2023-04-28
### Added
- Added the ability to import options fields (multi-select, checkboxes, etc.) into contact fields ([#380](https://github.com/putyourlightson/craft-campaign/issues/380)).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-campaign",
"description": "Send and manage email campaigns, contacts and mailing lists.",
"version": "2.6.1",
"version": "2.6.2",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand Down
10 changes: 6 additions & 4 deletions src/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,12 @@ public function userCanEditContacts(): bool
return false;
}

// Edit permission for the primary site is required to edit contacts
$primarySite = Craft::$app->getSites()->getPrimarySite();
if (!$currentUser->can('editSite:' . $primarySite->uid)) {
return false;
if (Craft::$app->getIsMultiSite()) {
// Edit permission for the primary site is required to edit contacts
$primarySite = Craft::$app->getSites()->getPrimarySite();
if (!$currentUser->can('editSite:' . $primarySite->uid)) {
return false;
}
}

return true;
Expand Down

0 comments on commit 8ff218a

Please sign in to comment.