first implementation of security

This commit is contained in:
Nicolas Lœuillet
2015-01-31 15:14:10 +01:00
parent 71691fe44a
commit c3235553dd
18 changed files with 469 additions and 69 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace Wallabag\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContext;
class SecurityController extends Controller
{
public function loginAction(Request $request)
{
$session = $request->getSession();
// get the login error if there is one
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render('WallabagCoreBundle:Security:login.html.twig', array(
// last username entered by the user
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
}
}

View File

@ -82,17 +82,18 @@ class WallabagRestController extends Controller
*/
public function postEntriesAction(Request $request)
{
//TODO la récup ne marche
//TODO la récup ne marche pas
//TODO gérer si on passe le titre
//TODO gérer si on passe les tags
//TODO ne pas avoir du code comme ça qui doit se trouver dans le Repository
$url = $request->request->get('url');
$content = Extractor::extract($url);
$entry = new Entries();
$entry->setUserId(1);
$content = Extractor::extract($request->request->get('url'));
$entry->setUrl($url);
$entry->setTitle($content->getTitle());
$entry->setContent($content->getBody());
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();