Skip to content

Commit 80d6efe

Browse files
committed
feature #951 Block login page for logged in users (Carrancio)
This PR was squashed before being merged into the master branch (closes #951). Discussion ---------- Block login page for logged in users This PR blocks the login page for logged in users. Commits ------- 13000f2 Block login page for logged in users
2 parents 87af67a + 13000f2 commit 80d6efe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Controller/SecurityController.php

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

1414
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\Routing\Annotation\Route;
@@ -34,6 +35,11 @@ class SecurityController extends AbstractController
3435
*/
3536
public function login(Request $request, AuthenticationUtils $helper): Response
3637
{
38+
// Block login page for logged in users
39+
if ($this->container->get('security.authorization_checker')->isGranted('ROLE_USER')) {
40+
return $this->redirectToRoute('blog_index');
41+
}
42+
3743
// this statement solves an edge-case: if you change the locale in the login
3844
// page, after a successful login you are redirected to a page in the previous
3945
// locale. This code regenerates the referrer URL whenever the login page is

0 commit comments

Comments
 (0)