Auto-login after invitation registration, redirect to /mon-compte

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-22 22:49:41 +01:00
parent ef06066794
commit 517e31f2f7
2 changed files with 7 additions and 4 deletions

View File

@@ -14,7 +14,7 @@
### Invitations Organisateur
- [ ] Bloquer l'envoi d'invitations (billets) si Stripe n'est pas validé sur le compte orga
- [ ] Après inscription via invitation, connecter automatiquement l'utilisateur
- [x] Après inscription via invitation, connecter automatiquement l'utilisateur
- [x] Empêcher la double inscription (même email) avec message clair et redirect vers login
- [x] Ajouter une notification admin quand un orga accepte/refuse une invitation

View File

@@ -13,6 +13,7 @@ use App\Service\EventIndexService;
use App\Service\MailerService;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -346,7 +347,7 @@ class HomeController extends AbstractController
}
#[Route('/invitation/{token}/inscription', name: 'app_invitation_register', methods: ['GET', 'POST'])]
public function invitationRegister(string $token, Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordHasher): Response
public function invitationRegister(string $token, Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordHasher, Security $security): Response
{
$invitation = $em->getRepository(OrganizerInvitation::class)->findOneBy(['token' => $token]);
if (!$invitation || OrganizerInvitation::STATUS_ACCEPTED !== $invitation->getStatus()) {
@@ -396,9 +397,11 @@ class HomeController extends AbstractController
$em->persist($user);
$em->flush();
$this->addFlash('success', 'Votre compte organisateur a ete cree. Connectez-vous pour commencer.');
$security->login($user, 'form_login');
return $this->redirectToRoute('app_home');
$this->addFlash('success', 'Bienvenue ! Votre compte organisateur est actif.');
return $this->redirectToRoute('app_account');
}
return $this->render('home/invitation_register.html.twig', [