mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-23 16:10:28 +00:00
getSalt method
This commit is contained in:
parent
7ffb1e80bf
commit
c5e8ba25bb
3 changed files with 26 additions and 7 deletions
|
@ -18,11 +18,6 @@ login_check:
|
||||||
logout:
|
logout:
|
||||||
path: /logout
|
path: /logout
|
||||||
|
|
||||||
#wallabag_api:
|
|
||||||
# resource: "@WallabagApiBundle/Controller/"
|
|
||||||
# type: annotation
|
|
||||||
# prefix: /api
|
|
||||||
|
|
||||||
rest :
|
rest :
|
||||||
type : rest
|
type : rest
|
||||||
resource : "routing_rest.yml"
|
resource : "routing_rest.yml"
|
||||||
|
|
|
@ -56,6 +56,7 @@ security:
|
||||||
target: /
|
target: /
|
||||||
|
|
||||||
access_control:
|
access_control:
|
||||||
|
- { path: ^/api/salt, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/, roles: ROLE_USER }
|
- { path: ^/, roles: ROLE_USER }
|
||||||
|
|
|
@ -8,10 +8,34 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Wallabag\CoreBundle\Entity\Entry;
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
use Wallabag\CoreBundle\Entity\Tags;
|
use Wallabag\CoreBundle\Entity\Tags;
|
||||||
|
use Wallabag\CoreBundle\Entity\User;
|
||||||
use Wallabag\CoreBundle\Service\Extractor;
|
use Wallabag\CoreBundle\Service\Extractor;
|
||||||
|
|
||||||
class WallabagRestController extends Controller
|
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 $user->getSalt();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve all entries. It could be filtered by many options.
|
* Retrieve all entries. It could be filtered by many options.
|
||||||
*
|
*
|
||||||
|
@ -85,8 +109,7 @@ class WallabagRestController extends Controller
|
||||||
$url = $request->request->get('url');
|
$url = $request->request->get('url');
|
||||||
|
|
||||||
$content = Extractor::extract($url);
|
$content = Extractor::extract($url);
|
||||||
$entry = new Entry();
|
$entry = new Entry($this->getUser()->getId());
|
||||||
$entry->setUserId($this->getUser()->getId());
|
|
||||||
$entry->setUrl($url);
|
$entry->setUrl($url);
|
||||||
$entry->setTitle($request->request->get('title') ?: $content->getTitle());
|
$entry->setTitle($request->request->get('title') ?: $content->getTitle());
|
||||||
$entry->setContent($content->getBody());
|
$entry->setContent($content->getBody());
|
||||||
|
|
Loading…
Reference in a new issue