Skip to content

Commit 24f825e

Browse files
committed
Refactored code
1 parent 80d6efe commit 24f825e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Controller/SecurityController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
namespace App\Controller;
1313

1414
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
15-
use Symfony\Component\HttpFoundation\RedirectResponse;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\Routing\Annotation\Route;
1918
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
2019
use Symfony\Component\Security\Http\Util\TargetPathTrait;
20+
use Symfony\Component\Security\Core\Security;
2121

2222
/**
2323
* Controller used to manage the application security.
@@ -33,10 +33,10 @@ class SecurityController extends AbstractController
3333
/**
3434
* @Route("/login", name="security_login")
3535
*/
36-
public function login(Request $request, AuthenticationUtils $helper): Response
36+
public function login(Request $request, Security $security, AuthenticationUtils $helper): Response
3737
{
38-
// Block login page for logged in users
39-
if ($this->container->get('security.authorization_checker')->isGranted('ROLE_USER')) {
38+
// if user is already logged in, don't display the login page again
39+
if ($security->isGranted('ROLE_USER')) {
4040
return $this->redirectToRoute('blog_index');
4141
}
4242

0 commit comments

Comments
 (0)