Skip to content

Commit

Permalink
requireAdmin() now factors in the allowAdminChanges config setting
Browse files Browse the repository at this point in the history
Resolves #3728
  • Loading branch information
brandonkelly committed Jan 28, 2019
1 parent e9e7ac8 commit 1eb7eba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Changed
- `craft\web\Controller::requireAdmin()` now sends a 403 (Forbidden) response if the `allowAdminChanges` config setting has been set to `false`. ([#3728](https://github.com/craftcms/cms/issues/3728))

### Fixed
- Fixed an erroc that occurred when uing the `json_decode` filter. ([#3722](https://github.com/craftcms/cms/pull/3722))
- Fixed a bug a bug where plugin screenshots in teh Plugin Store were not rendering correctly. ([#3709](https://github.com/craftcms/cms/issues/3709))
Expand Down
5 changes: 5 additions & 0 deletions src/web/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ public function requireAdmin()
if (!Craft::$app->getUser()->getIsAdmin()) {
throw new ForbiddenHttpException('User is not permitted to perform this action.');
}

// Make sure admin changes are allowed
if (!Craft::$app->getConfig()->getGeneral()->allowAdminChanges) {
throw new ForbiddenHttpException('Administrative changes are disallowed in this environment.');
}
}

/**
Expand Down

0 comments on commit 1eb7eba

Please sign in to comment.