Task: Deny access to loginform in active sessions
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controller\Security;
|
namespace App\Controller\Security;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
@@ -12,6 +13,12 @@ class LoginController extends AbstractController
|
|||||||
#[Route('/login', name: 'app_security_login')]
|
#[Route('/login', name: 'app_security_login')]
|
||||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||||
{
|
{
|
||||||
|
// redirect to default route in case of active session
|
||||||
|
if (null !== $user = $this->getUser()) {
|
||||||
|
/** @var User $user */
|
||||||
|
return $this->redirectToRoute($user->getDefaultRoute());
|
||||||
|
}
|
||||||
|
|
||||||
// get the login error if there is one
|
// get the login error if there is one
|
||||||
$error = $authenticationUtils->getLastAuthenticationError();
|
$error = $authenticationUtils->getLastAuthenticationError();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user