user gestion fully done
This commit is contained in:
@@ -45,6 +45,7 @@ security:
|
||||
- { path: ^/login, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/password, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/register, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/inscription, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/admin, roles: ROLE_ADMIN }
|
||||
- { path: ^/, roles: ROLE_USER }
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20241120093750 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE password_reset_token (id_password_reset_token CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', token VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id_password_reset_token)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE participant DROP file_name');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE password_reset_token');
|
||||
$this->addSql('ALTER TABLE participant ADD file_name VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20241120095413 extends AbstractMigration
|
||||
final class Version20241120131557 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
@@ -20,12 +20,12 @@ final class Version20241120095413 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE participant ADD file_name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE participant ADD pending TINYINT(1) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE participant DROP file_name');
|
||||
$this->addSql('ALTER TABLE participant DROP pending');
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Entity\Ville;
|
||||
use App\Repository\ParticipantRepository;
|
||||
use App\Repository\SiteRepository;
|
||||
use App\Repository\VilleRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -376,4 +377,49 @@ class AdminController extends AbstractController
|
||||
$this->addFlash('success', 'Site supprimée avec succès.');
|
||||
return $this->redirectToRoute('app_adminSite');
|
||||
}
|
||||
|
||||
#[Route('/admin/accept', name: 'app_acceptUser')]
|
||||
public function acceptUser(Request $request, EntityManagerInterface $entityManager, ParticipantRepository $participantRepository): Response
|
||||
{
|
||||
try {
|
||||
$user = $participantRepository->findOneBy(["idParticipant" => $request->get('id')]);
|
||||
|
||||
if(!$user) {
|
||||
$this->addFlash('error', 'Le utilisateur n\'existe pas.');
|
||||
return $this->redirectToRoute('app_adminUser');
|
||||
}
|
||||
|
||||
$user->setPending(false);
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', "L'utilisateur à bien été accepté et peut maintenant se connecter");
|
||||
return $this->redirectToRoute('app_adminUser');
|
||||
} catch(\Exception $e) {
|
||||
$this->addFlash('error', "Erreur : " . $e->getMessage());
|
||||
return $this->redirectToRoute('home');
|
||||
}
|
||||
}
|
||||
|
||||
#[Route('/admin/deny', name: 'app_denyUser')]
|
||||
public function denyUser(Request $request, EntityManagerInterface $entityManager, ParticipantRepository $participantRepository): Response
|
||||
{
|
||||
try {
|
||||
$user = $participantRepository->findOneBy(["idParticipant" => $request->get('id')]);
|
||||
|
||||
if(!$user) {
|
||||
$this->addFlash('error', 'Le utilisateur n\'existe pas.');
|
||||
return $this->redirectToRoute('app_adminUser');
|
||||
}
|
||||
|
||||
$entityManager->remove($user);
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', "L'utilisateur à bien été refusé et ne pourra pas se connecter");
|
||||
return $this->redirectToRoute('app_adminUser');
|
||||
} catch(\Exception $e) {
|
||||
$this->addFlash('error', "Erreur : " . $e->getMessage());
|
||||
return $this->redirectToRoute('home');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,10 @@ class MainController extends AbstractController
|
||||
'profile' => $userConnect,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/inscription', name: 'inscription')]
|
||||
public function inscription(TokenStorageInterface $tokenStorage): Response
|
||||
{
|
||||
return $this->render('main/inscription.html.twig');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class RegistrationController extends AbstractController
|
||||
$user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword));
|
||||
$user->setRoles(['ROLE_USER']);
|
||||
$user->setActif(false);
|
||||
$user->setPending(true);
|
||||
if ($user->getRoles() == 'ROLE_ADMIN') {
|
||||
$user->setAdministrateur(true);
|
||||
} else {
|
||||
@@ -47,8 +48,8 @@ class RegistrationController extends AbstractController
|
||||
|
||||
// do anything else you need here, like send an email
|
||||
|
||||
// return $this->redirectToRoute('home');
|
||||
return $security->login($user, 'form_login', 'main');
|
||||
return $this->redirectToRoute('inscription');
|
||||
// return $security->login($user, 'form_login', 'main');
|
||||
}
|
||||
|
||||
return $this->render('auth/register.html.twig', [
|
||||
|
||||
@@ -41,6 +41,9 @@ class Participant implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\Column]
|
||||
private ?bool $actif = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $pending = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private array $roles = [];
|
||||
|
||||
@@ -82,6 +85,16 @@ class Participant implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPending(): ?bool
|
||||
{
|
||||
return $this->pending;
|
||||
}
|
||||
|
||||
public function setPending(?bool $pending): void
|
||||
{
|
||||
$this->pending = $pending;
|
||||
}
|
||||
|
||||
public function getPseudo(): ?string
|
||||
{
|
||||
return $this->pseudo;
|
||||
|
||||
@@ -46,7 +46,7 @@ class LoginFormAuthenticator extends AbstractAuthenticator
|
||||
'pseudo' => $identifier
|
||||
]);
|
||||
|
||||
if (!$user || $user->isActif()) {
|
||||
if (!$user || $user->isActif() || $user->getPending()) {
|
||||
throw new UserNotFoundException('Utilisateur non trouvé');
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
{% for participant in participants %}
|
||||
{% if not participant.pending %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.nom }}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.prenom }}</td>
|
||||
@@ -81,6 +82,7 @@
|
||||
<a href="{{ path('app_adminUserDelete', {'id': participant.idParticipant}) }}" class="text-red-600 hover:text-red-900 ml-4">Supprimer</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Aucun participant trouvé</td>
|
||||
@@ -89,8 +91,48 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{# Tableau user en attente #}
|
||||
<div class="overflow-x-auto bg-white rounded shadow mt-16">
|
||||
<table class="min-w-full bg-white divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Prénom</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Pseudo</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Téléphone</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
|
||||
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
{% for participant in participants %}
|
||||
{% if participant.pending %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.nom }}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.prenom }}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.pseudo }}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.telephone }}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.email }}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
<a href="{{ path('app_acceptUser', {'id': participant.idParticipant}) }}" class="text-indigo-600 hover:text-indigo-900">
|
||||
Accepter
|
||||
</a>
|
||||
<a href="{{ path('app_denyUser', {'id': participant.idParticipant}) }}" class="text-red-600 hover:text-red-900 ml-4">Refuser</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Aucun participant en attente</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modale pour ajouter une ville -->
|
||||
</div>
|
||||
|
||||
<!-- Modale pour ajouter un user -->
|
||||
<div id="userModal" class="fixed inset-0 z-50 hidden bg-gray-900 bg-opacity-50">
|
||||
<div class="flex justify-center items-center min-h-screen">
|
||||
<div class="bg-white p-6 rounded shadow-md w-1/3">
|
||||
|
||||
18
templates/main/inscription.html.twig
Normal file
18
templates/main/inscription.html.twig
Normal file
@@ -0,0 +1,18 @@
|
||||
{% extends 'main/base.html.twig' %}
|
||||
{% block head %}
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{% block stylesheets %}
|
||||
{{ encore_entry_link_tags('app') }}
|
||||
{% endblock %}
|
||||
</head>
|
||||
{% endblock %}
|
||||
|
||||
{%block content %}
|
||||
<div class="flex justify-center items-center py-52">
|
||||
<div class="bg-white shadow-lg rounded-lg p-8 max-w-md text-center">
|
||||
<h3 class="text-2xl font-bold text-center pb-3">Bonjour,</h3>
|
||||
<p class="text-gray-700 text-justify mb-4">Vous venez de vous inscrire à notre plateforme d'évenementiels. <br> Un administrateur traite votre demande d'inscription et va donner son verdict d'ici quelques instant.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user