X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FWallabagRestController.php;h=fcd212efb4507a4383bc41d1e7edcb97ee0a511c;hb=e1dd7f70c5cc0a0086d83d5fcdaa7a25081a5e6f;hp=4784cb012992d804b4b3573018d74d5791ae94ef;hpb=3d3368cfd5e8dbe320428f479a49cabfddc58acd;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 4784cb01..fcd212ef 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 string + */ + public function getSaltAction($username) + { + $user = $this + ->getDoctrine() + ->getRepository('WallabagCoreBundle:User') + ->findOneByUsername($username); + + if (is_null($user)) { + throw $this->createNotFoundException(); + } + + return array($user->getSalt()); + } /** * Retrieve all entries. It could be filtered by many options. * @@ -43,7 +66,7 @@ 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 (!($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());