diff options
author | Jeremy <j0k3r@users.noreply.github.com> | 2015-02-10 13:49:57 +0100 |
---|---|---|
committer | Jeremy <j0k3r@users.noreply.github.com> | 2015-02-10 13:49:57 +0100 |
commit | 2c0ffcf3972e2f58267b805a26835f452e016761 (patch) | |
tree | b1146d6a9b98bb2ce238fff10fed4a1bf872c4b4 /src/Wallabag/CoreBundle/Controller | |
parent | cbce162b407024882d8c37a7e3298c85175d2651 (diff) | |
parent | 92504e0dd489c0d11abc87bee42ffca717db0480 (diff) | |
download | wallabag-2c0ffcf3972e2f58267b805a26835f452e016761.tar.gz wallabag-2c0ffcf3972e2f58267b805a26835f452e016761.tar.zst wallabag-2c0ffcf3972e2f58267b805a26835f452e016761.zip |
Merge pull request #1068 from wallabag/v2-api-authentication
V2 api authentication
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 1 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 28 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index e0697ca3..5378486a 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -6,7 +6,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\CoreBundle\Entity\Entry; | 8 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\CoreBundle\Repository; | ||
10 | use Wallabag\CoreBundle\Service\Extractor; | 9 | use Wallabag\CoreBundle\Service\Extractor; |
11 | use Wallabag\CoreBundle\Helper\Url; | 10 | use Wallabag\CoreBundle\Helper\Url; |
12 | 11 | ||
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index c298d849..f77a3749 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -13,6 +13,29 @@ use Wallabag\CoreBundle\Service\Extractor; | |||
13 | class WallabagRestController extends Controller | 13 | class WallabagRestController extends Controller |
14 | { | 14 | { |
15 | /** | 15 | /** |
16 | * Retrieve salt for a giver user. | ||
17 | * | ||
18 | * @ApiDoc( | ||
19 | * parameters={ | ||
20 | * {"name"="username", "dataType"="string", "required"=true, "description"="username"} | ||
21 | * } | ||
22 | * ) | ||
23 | * @return string | ||
24 | */ | ||
25 | public function getSaltAction($username) | ||
26 | { | ||
27 | $user = $this | ||
28 | ->getDoctrine() | ||
29 | ->getRepository('WallabagCoreBundle:User') | ||
30 | ->findOneByUsername($username); | ||
31 | |||
32 | if (is_null($user)) { | ||
33 | throw $this->createNotFoundException(); | ||
34 | } | ||
35 | |||
36 | return $user->getSalt(); | ||
37 | } | ||
38 | /** | ||
16 | * Retrieve all entries. It could be filtered by many options. | 39 | * Retrieve all entries. It could be filtered by many options. |
17 | * | 40 | * |
18 | * @ApiDoc( | 41 | * @ApiDoc( |
@@ -43,7 +66,7 @@ class WallabagRestController extends Controller | |||
43 | $entries = $this | 66 | $entries = $this |
44 | ->getDoctrine() | 67 | ->getDoctrine() |
45 | ->getRepository('WallabagCoreBundle:Entry') | 68 | ->getRepository('WallabagCoreBundle:Entry') |
46 | ->findEntries(1, $isArchived, $isStarred, $isDeleted, $sort, $order); | 69 | ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isDeleted, $sort, $order); |
47 | 70 | ||
48 | if (!is_array($entries)) { | 71 | if (!is_array($entries)) { |
49 | throw $this->createNotFoundException(); | 72 | throw $this->createNotFoundException(); |
@@ -85,8 +108,7 @@ class WallabagRestController extends Controller | |||
85 | $url = $request->request->get('url'); | 108 | $url = $request->request->get('url'); |
86 | 109 | ||
87 | $content = Extractor::extract($url); | 110 | $content = Extractor::extract($url); |
88 | $entry = new Entry(); | 111 | $entry = new Entry($this->getUser()); |
89 | $entry->setUserId(1); | ||
90 | $entry->setUrl($url); | 112 | $entry->setUrl($url); |
91 | $entry->setTitle($request->request->get('title') ?: $content->getTitle()); | 113 | $entry->setTitle($request->request->get('title') ?: $content->getTitle()); |
92 | $entry->setContent($content->getBody()); | 114 | $entry->setContent($content->getBody()); |