add more log on AccessDeniedException

This commit is contained in:
Nicolas Lœuillet 2015-03-05 19:34:30 +01:00
parent 2ab8cb6816
commit efad7e53a1
1 changed files with 13 additions and 9 deletions

View File

@ -40,7 +40,11 @@ class WallabagRestController extends Controller
/** /**
* Retrieve salt for a giver user. * Retrieve salt for a giver user.
* *
* @ApiDoc() * @ApiDoc(
* parameters={
* {"name"="username", "dataType"="string", "required"=true, "description"="username"}
* }
* )
* @return array * @return array
*/ */
public function getSaltAction($username) public function getSaltAction($username)
@ -87,7 +91,7 @@ class WallabagRestController extends Controller
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order); ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order);
if (!($entries)) { if (!$entries) {
throw $this->createNotFoundException(); throw $this->createNotFoundException();
} }
@ -109,7 +113,7 @@ class WallabagRestController extends Controller
public function getEntryAction(Entry $entry) public function getEntryAction(Entry $entry)
{ {
if ($entry->getUser()->getId() != $this->getUser()->getId()) { if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$entry->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$json = $this->get('serializer')->serialize($entry, 'json'); $json = $this->get('serializer')->serialize($entry, 'json');
@ -172,7 +176,7 @@ class WallabagRestController extends Controller
public function patchEntriesAction(Entry $entry, Request $request) public function patchEntriesAction(Entry $entry, Request $request)
{ {
if ($entry->getUser()->getId() != $this->getUser()->getId()) { if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$entry->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$title = $request->request->get("title"); $title = $request->request->get("title");
@ -217,7 +221,7 @@ class WallabagRestController extends Controller
public function deleteEntriesAction(Entry $entry) public function deleteEntriesAction(Entry $entry)
{ {
if ($entry->getUser()->getId() != $this->getUser()->getId()) { if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$entry->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -241,7 +245,7 @@ class WallabagRestController extends Controller
public function getEntriesTagsAction(Entry $entry) public function getEntriesTagsAction(Entry $entry)
{ {
if ($entry->getUser()->getId() != $this->getUser()->getId()) { if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$entry->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$json = $this->get('serializer')->serialize($entry->getTags(), 'json'); $json = $this->get('serializer')->serialize($entry->getTags(), 'json');
@ -264,7 +268,7 @@ class WallabagRestController extends Controller
public function postEntriesTagsAction(Request $request, Entry $entry) public function postEntriesTagsAction(Request $request, Entry $entry)
{ {
if ($entry->getUser()->getId() != $this->getUser()->getId()) { if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$entry->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$tags = $request->request->get('tags', ''); $tags = $request->request->get('tags', '');
@ -294,7 +298,7 @@ class WallabagRestController extends Controller
public function deleteEntriesTagsAction(Entry $entry, Tag $tag) public function deleteEntriesTagsAction(Entry $entry, Tag $tag)
{ {
if ($entry->getUser()->getId() != $this->getUser()->getId()) { if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$entry->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$entry->removeTag($tag); $entry->removeTag($tag);
@ -331,7 +335,7 @@ class WallabagRestController extends Controller
public function deleteTagAction(Tag $tag) public function deleteTagAction(Tag $tag)
{ {
if ($tag->getUser()->getId() != $this->getUser()->getId()) { if ($tag->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException(); throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$tag->getUser()->getId().', logged user id: '.$this->getUser()->getId());
} }
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();