added validator
This commit is contained in:
@ -2,17 +2,38 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Blog;
|
||||
use App\Repository\BlogRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* Class BlogController
|
||||
* @package App\Controller
|
||||
*/
|
||||
class BlogController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'blog')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('blog/index.html.twig', [
|
||||
'controller_name' => 'BlogController',
|
||||
]);
|
||||
}
|
||||
#[Route('/', name: 'blogs')]
|
||||
public function index(BlogRepository $blogRepository): Response
|
||||
{
|
||||
return $this->render('blog/index.html.twig', [
|
||||
'blogs' => $blogRepository->findAll()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param \App\Repository\BlogRepository $blogRepository
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
#[Route('/blog/{id}', name: 'blog')]
|
||||
public function show($id, BlogRepository $blogRepository): Response
|
||||
{
|
||||
return $this->render('blog/show.html.twig', [
|
||||
'blog' => $blogRepository->findOneBy(['id' => $id])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -147,8 +147,8 @@ class AppAuthenticator extends AbstractFormLoginAuthenticator implements Passwor
|
||||
*/
|
||||
public function checkCredentials($credentials, UserInterface $user)
|
||||
{
|
||||
return true;
|
||||
//return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
|
||||
//return true;
|
||||
return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ class AppAuthenticator extends AbstractFormLoginAuthenticator implements Passwor
|
||||
return new RedirectResponse($targetPath);
|
||||
}
|
||||
|
||||
return new RedirectResponse($this->urlGenerator->generate('blog'));
|
||||
return new RedirectResponse($this->urlGenerator->generate('blogs'));
|
||||
}
|
||||
|
||||
protected function getLoginUrl()
|
||||
|
Reference in New Issue
Block a user