feat/cnx_api #11

Merged
maurine merged 15 commits from feat/cnx_api into main 2026-03-30 12:08:52 +02:00
3 changed files with 6 additions and 36 deletions
Showing only changes of commit 627f5b6954 - Show all commits

View File

@@ -8,11 +8,9 @@ use Symfony\Component\Routing\Attribute\Route;
class HomeController extends AbstractController
{
#[Route('/hello', name: 'app_home', methods: ['GET'])]
public function hello(): Response
{
return $this->render('home/hello.html.twig', [
'name' => 'Melvin'
]);
}
#[Route(path: '/', name: 'app_home', methods: ['GET'])]
public function home(): Response
{
return $this->render('home/home.html.twig');
}
}

View File

@@ -2,8 +2,6 @@
namespace App\Controller;
use App\Repository\UserRepository; // 👈 AJOUTE CETTE LIGNE ICI !
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; // 👈 ET CELLE-CI AUSSI !
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -12,35 +10,9 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
#[Route(path: '/test-password', name: 'test_password')]
public function testPassword(UserRepository $userRepo, UserPasswordHasherInterface $hasher): Response
{
// 1. On va chercher ton admin directement en base
$admin = $userRepo->findOneBy(['email' => 'admin@kaz.fr']);
if (!$admin) {
dd("L'utilisateur n'existe pas dans la base lue par ce contrôleur !");
}
// 2. On vérifie si "password" est bien le bon mot de passe
$isValid = $hasher->isPasswordValid($admin, 'password');
// 3. On affiche le résultat brut
dd([
'email' => $admin->getEmail(),
'mot_de_passe_hache' => $admin->getPassword(),
'est_ce_que_password_est_valide' => $isValid
]);
}
#[Route(path: '/login', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils, Request $request): Response // 👈 2. ON AJOUTE $request ICI
public function login(AuthenticationUtils $authenticationUtils, Request $request): Response
{
// 🚨 3. NOTRE CODE DE DÉTECTIVE POUR VOIR CE QUI EST ENVOYÉ :
if ($request->isMethod('POST')) {
dd($request->request->all());
}
// 🚨 FIN DU CODE DE DÉTECTIVE
if ($this->getUser()) {
return $this->redirectToRoute('app_home');
}