X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FWallabagRestController.php;h=e9cd8c93922da75efa0d4b93f0e6822d85d7dc21;hb=e4977b8a866f84f65f08c55c050a62f40170fdbf;hp=ab2c1181c11659c0653655b7df0eda4bf7bcf0e1;hpb=eaf95758dc3ebc0e666a8317cd37311f03cd2233;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index ab2c1181..e9cd8c93 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php @@ -12,6 +12,29 @@ use Wallabag\CoreBundle\Service\Extractor; class WallabagRestController extends Controller { + /** + * Retrieve salt for a giver user. + * + * @ApiDoc( + * parameters={ + * {"name"="username", "dataType"="string", "required"=true, "description"="username"} + * } + * ) + * @return array + */ + public function getSaltAction($username) + { + $user = $this + ->getDoctrine() + ->getRepository('WallabagCoreBundle:User') + ->findOneByUsername($username); + + if (is_null($user)) { + throw $this->createNotFoundException(); + } + + return array($user->getSalt() ?: null); + } /** * Retrieve all entries. It could be filtered by many options. * @@ -43,9 +66,9 @@ class WallabagRestController extends Controller $entries = $this ->getDoctrine() ->getRepository('WallabagCoreBundle:Entry') - ->findEntries(1, $isArchived, $isStarred, $isDeleted, $sort, $order); + ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isDeleted, $sort, $order); - if (is_null($entries)) { + if (!($entries)) { throw $this->createNotFoundException(); } @@ -85,8 +108,7 @@ class WallabagRestController extends Controller $url = $request->request->get('url'); $content = Extractor::extract($url); - $entry = new Entry(); - $entry->setUserId(1); + $entry = new Entry($this->getUser()); $entry->setUrl($url); $entry->setTitle($request->request->get('title') ?: $content->getTitle()); $entry->setContent($content->getBody());