<?php
namespace App\Controller;
use App\Entity\Users;
use App\Repository\PaniersRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
/**
* @Route("/login", name="login")
*/
public function login(AuthenticationUtils $authenticationUtils){
$error = $authenticationUtils->getLastAuthenticationError();
$last_username=$authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig',[
'error' => $error,
'last_username' => $last_username
]
);
}
/**
* @Route("/logincrm", name="logincrm")
*/
public function loginsalarie(AuthenticationUtils $authenticationUtils){
$error = $authenticationUtils->getLastAuthenticationError();
$last_username=$authenticationUtils->getLastUsername();
return $this->render('security/logincrm.html.twig',[
'error' => $error,
'last_username' => $last_username
]
);
}
/**
* @Route("/login_success", name="login_success")
*/
public function postLoginRedirectAction()
{
if( $this->isGranted('ROLE_ADMIN') || $this->isGranted('ROLE_SALARIE') ) {
return $this->redirectToRoute("crm.tdb");
} elseif( $this->isGranted('ROLE_USER') )
{
return $this->redirectToRoute("dashboard.tdb");
}
elseif( $this->isGranted('ROLE_PRESTA') )
{
return $this->redirectToRoute("prestataires.tdb");
} else {
return $this->redirectToRoute("login");
}
}
}
?>