mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-01 17:38:38 +00:00
Merge pull request #1068 from wallabag/v2-api-authentication
V2 api authentication
This commit is contained in:
commit
2c0ffcf397
11 changed files with 95 additions and 56 deletions
|
@ -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 $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 (!is_array($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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue