Commit e93ba70a authored by Baudouin Feildel's avatar Baudouin Feildel
Browse files

Redirect to dashboard in case login page is opened while logged-in

parent 3beffb61
Pipeline #484 passed with stage
in 1 minute and 30 seconds
......@@ -10,6 +10,7 @@ use App\Entity\Content\Panel;
use App\Repository\Content\DdecRepository;
use App\Security\PageVoter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
......@@ -60,9 +61,14 @@ class SessionController extends AbstractController
*/
public function getFrontLogin(Request $request, AuthenticationUtils $authUtils)
{
$target_path = $request->request->get('_target_path');
if ($this->isGranted('ROLE_USER')) {
return new RedirectResponse($target_path ?? $this->generateUrl('user_dashboard'));
}
$error = $authUtils->getLastAuthenticationError();
$lastUsername = $authUtils->getLastUsername();
$target_path = $request->request->get('_target_path');
return $this->render('login.html.twig', [
'last_username' => $lastUsername,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment