cakephp 2.6
opauthでログインして投稿した内容を自分のみ編集・削除可能のようにしたいのですが、
下記のチュートリアルの記述をしましたが、うまく動きません。
なにか、別の記述をする必要があるのでしょうか?
php
1public function isAuthorized($user) { 2 // 登録済ユーザーは投稿できる 3 if ($this->action === 'add') { 4 return true; 5 } 6 7 // 投稿のオーナーは編集や削除ができる 8 if (in_array($this->action, array('edit', 'delete'))) { 9 $postId = (int) $this->request->params['pass'][0]; 10 if ($this->Post->isOwnedBy($postId, $user['id'])) { 11 return true; 12 } 13 } 14 15 return parent::isAuthorized($user); 16}
php
1public function isOwnedBy($post, $user) { 2 return $this->field('id', array('id' => $post, 'user_id' => $user)) !== false; 3}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。