これはコントローラーにあります。
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'));
}
私のモデルは次のようになります:(belongsTo)
<?php
class Memberlist extends AppModel {
public $name = 'Memberlist';
public $belongsTo = array(
'Account' => array(
'className' => 'Account',
'foreignKey' => 'account_id'
)
);
私の見解の1つでは、次のようなものがあります。
echo $this->Form->postLink('Delete',
array('action' => 'delete', $list['Memberlist']['id']),
array('class'=>'btn-mini btn', 'confirm' => 'Are you sure?'));
これにより、次のようなHTMLが作成されます。
<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>
ID
問題は、Firebug(または任意の開発者ツール)を使用して見つかったものを更新すると、action="/Grid/memberlists/delete/9"
ほとんど何でも削除できることです!別のアカウントからでも。セキュリティコンポーネントをオンにしているのに。
これを行うための適切な方法は何でしょうか?account_id
現在ログインしているユーザーのaccount_idと照合することを考えています。しかし、CakePHPにこの問題を修正するためのすぐに使えるものがあるかどうか、私はただ興味がありますか?