Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:55:11+00:00 2026-06-06T02:55:11+00:00

I have this in my Controller. public function delete($id) { if($this->request->is(‘get’)) { throw new

  • 0

I have this in my Controller.

public function delete($id) {
    if($this->request->is('get')) {
        throw new MethodNotAllowedException();
    }

    $this->Memberlist->id = $id;
    if (!$this->Memberlist->exists()) {
        throw new NotFoundException(__('Invalid list.'));
    }
    if ($this->Memberlist->delete()) {
        $this->Session->setFlash(__('List deleted.'), 'success');
        return $this->redirect(array('action'=>'index'));
    }
    $this->Session->setFlash(__('List was not deleted.'), 'error');
    return $this->redirect(array('action'=>'index'));
}

My Model looks like this: (belongsTo)

<?php

class Memberlist extends AppModel {
    public $name = 'Memberlist';
    public $belongsTo = array(
            'Account' => array(
            'className' => 'Account',
            'foreignKey' => 'account_id'
        )
    );

In one of my views, I have something like this:

echo $this->Form->postLink('Delete', 
                    array('action' => 'delete', $list['Memberlist']['id']),
                    array('class'=>'btn-mini btn', 'confirm' => 'Are you sure?'));

Which creates a HTML like this:

<form id="post_4fe15efc0d284" method="post" style="display:none;" name="post_4fe15efc0d284" action="/Grid/memberlists/delete/9">
<input type="hidden" value="POST" name="_method">
<input id="Token1627936788" type="hidden" value="8756f7ad21f3ab93dd6fb9a4861e3aed4496f3f9" name="data[_Token][key]">
<div style="display:none;">
</form>
<a class="btn-mini btn" onclick="if (confirm('Are you sure?')) { document.post_4fe15efc0d284.submit(); } event.returnValue = false; return false;" href="#">Delete</a>

The problem is that when I update the ID found in action="/Grid/memberlists/delete/9" using Firebug (or any developer tool), I can pretty much delete anything! Even from a different account. Even though I have the Security Component turned on.

What would be the proper way to do this? I am thinking of checking the account_id against the account_id of the currently logged-in user. But I am just curious if CakePHP has something out-of-the-box that fixes this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:55:12+00:00Added an answer on June 6, 2026 at 2:55 am

    You could add beforeDelete callback into your model, and query database and check if user is allowed to delete record and or is he owner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 functions/methods in the same controller in CodeIgniter like this: public function
i have this controller function: Public Function Index(ByVal id As System.Nullable(Of Integer)) As ActionResult
I have this controller method: public JsonResult List(int number) { var list = new
This is what I have: class Calendar extends CI_Controller { public $extension; function __construct()
I am getting some unexpected behavior from Html.EditorFor(). I have this controller: [HandleError] public
I have a simple Controller that looks like this:- @Controller @RequestMapping(value = /groups) public
I have this in my controller: MyTestViewModel asdf = new MyTestViewModel { SomeTestDate =
I have this controller: [HttpPost] public ActionResult Create(Company company) { // try to save
Let's say I have a controller template with a before function like so... public
I have a MY_Controller class with this property: class MY_Controller extends CI_Controller { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.