aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/config/routing.yml5
-rw-r--r--app/config/security.yml1
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php27
3 files changed, 26 insertions, 7 deletions
diff --git a/app/config/routing.yml b/app/config/routing.yml
index 426dcdcf..20f6979a 100644
--- a/app/config/routing.yml
+++ b/app/config/routing.yml
@@ -18,11 +18,6 @@ login_check:
18logout: 18logout:
19 path: /logout 19 path: /logout
20 20
21#wallabag_api:
22# resource: "@WallabagApiBundle/Controller/"
23# type: annotation
24# prefix: /api
25
26rest : 21rest :
27 type : rest 22 type : rest
28 resource : "routing_rest.yml" 23 resource : "routing_rest.yml"
diff --git a/app/config/security.yml b/app/config/security.yml
index 4a798e56..e06c8967 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -56,6 +56,7 @@ security:
56 target: / 56 target: /
57 57
58 access_control: 58 access_control:
59 - { path: ^/api/salt, roles: IS_AUTHENTICATED_ANONYMOUSLY }
59 - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY } 60 - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
60 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 61 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
61 - { path: ^/, roles: ROLE_USER } 62 - { path: ^/, roles: ROLE_USER }
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index 75e5204e..96d2529a 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -8,11 +8,35 @@ use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; 8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tags; 10use Wallabag\CoreBundle\Entity\Tags;
11use Wallabag\CoreBundle\Entity\User;
11use Wallabag\CoreBundle\Service\Extractor; 12use Wallabag\CoreBundle\Service\Extractor;
12 13
13class WallabagRestController extends Controller 14class WallabagRestController extends Controller
14{ 15{
15 /** 16 /**
17 * Retrieve salt for a giver user.
18 *
19 * @ApiDoc(
20 * parameters={
21 * {"name"="username", "dataType"="string", "required"=true, "description"="username"}
22 * }
23 * )
24 * @return string
25 */
26 public function getSaltAction($username)
27 {
28 $user = $this
29 ->getDoctrine()
30 ->getRepository('WallabagCoreBundle:User')
31 ->findOneByUsername($username);
32
33 if (is_null($user)) {
34 throw $this->createNotFoundException();
35 }
36
37 return $user->getSalt();
38 }
39 /**
16 * Retrieve all entries. It could be filtered by many options. 40 * Retrieve all entries. It could be filtered by many options.
17 * 41 *
18 * @ApiDoc( 42 * @ApiDoc(
@@ -85,8 +109,7 @@ class WallabagRestController extends Controller
85 $url = $request->request->get('url'); 109 $url = $request->request->get('url');
86 110
87 $content = Extractor::extract($url); 111 $content = Extractor::extract($url);
88 $entry = new Entry(); 112 $entry = new Entry($this->getUser()->getId());
89 $entry->setUserId($this->getUser()->getId());
90 $entry->setUrl($url); 113 $entry->setUrl($url);
91 $entry->setTitle($request->request->get('title') ?: $content->getTitle()); 114 $entry->setTitle($request->request->get('title') ?: $content->getTitle());
92 $entry->setContent($content->getBody()); 115 $entry->setContent($content->getBody());