Skip to content

Commit

Permalink
feat: Pointed API url to actionTrigger to support non-superuser acces…
Browse files Browse the repository at this point in the history
…s and lock down API controller
  • Loading branch information
reganlawton committed Sep 15, 2023
1 parent 6725d2d commit e276264
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Related Changelog

## 2.1.0 - 2023-09-15

### Updated
- Pointed API url to actionTrigger to support non-superuser access, thanks @Eviltoastey for the issue #23
- Locked down API controller to only allow users to access it to prevent data leakage

## 2.0.1 - 2023-01-11

### Updated
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wrav/related",
"description": "A simple plugin that adds a widget within the Craft CP page sidebar, allowing you to quickly and easily access related entries.",
"type": "craft-plugin",
"version": "2.0.1",
"version": "2.1.0",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 2 additions & 2 deletions src/assetbundles/related/dist/js/Related.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var sectionId = $("input[name='sectionId']").val() || '';
var categoryId = $("input[name='groupId']").val() || '';
var userId = $("input[name='userId']").val() || '';

var cpTrigger = Craft && Craft.cpTrigger ? Craft.cpTrigger : 'admin';
var actionTrigger = Craft && Craft.actionTrigger ? Craft.actionTrigger : 'actions';

// Add Settings element for User page which it's missing
if (!$("#settings").length) {
Expand All @@ -27,7 +27,7 @@ if (!$("#settings").length) {
if (id != null) {
$.ajax({
type: "GET",
url: "/"+cpTrigger.toString()+"/related/default?id=" + id + "&sectionId=" + sectionId + "&userId=" + userId + "&categoryId=" + categoryId,
url: "/"+actionTrigger.toString()+"/related/default?id=" + id + "&sectionId=" + sectionId + "&userId=" + userId + "&categoryId=" + categoryId,
async: true
}).done(function (res) {
if (res) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DefaultController extends Controller
* The actions must be in 'kebab-case'
* @access protected
*/
protected array|int|bool $allowAnonymous = ['index', 'do-something'];
protected array|int|bool $allowAnonymous = false; // Requires login to prevent data leakage

// Public Methods
// =========================================================================
Expand Down

0 comments on commit e276264

Please sign in to comment.