Merge branch 'Johan'
This commit is contained in:
BIN
public/upload/image/profile/pp-pro-673dcebc17a81.jpg
Normal file
BIN
public/upload/image/profile/pp-pro-673dcebc17a81.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -19,22 +19,29 @@ use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
class AdminController extends AbstractController
|
||||
{
|
||||
#[Route('/admin', name: 'app_admin')]
|
||||
public function index(): Response
|
||||
public function index(TokenStorageInterface $tokenStorage): Response
|
||||
{
|
||||
$token = $tokenStorage->getToken();
|
||||
$userConnect = $token?->getUser();
|
||||
return $this->render('admin/index.html.twig', [
|
||||
'profile' => $userConnect,
|
||||
'controller_name' => 'AdminController',
|
||||
]);
|
||||
}
|
||||
|
||||
//Gestion des utilisateurs
|
||||
#[Route('/admin/user', name: 'app_adminUser')]
|
||||
public function adminUser(ParticipantRepository $participantRepository): Response
|
||||
public function adminUser(ParticipantRepository $participantRepository, TokenStorageInterface $tokenStorage): Response
|
||||
{
|
||||
$token = $tokenStorage->getToken();
|
||||
$userConnect = $token?->getUser();
|
||||
return $this->render('admin/user.html.twig', [
|
||||
'profile' => $userConnect,
|
||||
'participants' => $participantRepository->findAll(),
|
||||
'controller_name' => 'AdminController',
|
||||
]);
|
||||
@@ -166,7 +173,7 @@ class AdminController extends AbstractController
|
||||
}
|
||||
}
|
||||
#[Route('/admin/user/import', name: 'participant_import', methods: ['POST'])]
|
||||
public function import(Request $request, EntityManagerInterface $em): RedirectResponse
|
||||
public function import(Request $request, EntityManagerInterface $em, MailerInterface $mailer, UrlGeneratorInterface $urlGenerator): RedirectResponse
|
||||
{
|
||||
$file = $request->files->get('csv_file');
|
||||
if ($file) {
|
||||
@@ -184,6 +191,39 @@ class AdminController extends AbstractController
|
||||
$participant->setRoles(explode('|', $row[7]));
|
||||
$participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT));
|
||||
$em->persist($participant);
|
||||
|
||||
// Générer un token unique
|
||||
$token = bin2hex(random_bytes(32));
|
||||
|
||||
// Enregistrer le token dans la base de données
|
||||
$passwordResetToken = new PasswordResetToken();
|
||||
$passwordResetToken->setToken($token)
|
||||
->setEmail($participant->getEmail())
|
||||
->setCreatedAt(new \DateTime());
|
||||
|
||||
$em->persist($passwordResetToken);
|
||||
|
||||
// Générer un lien de réinitialisation
|
||||
$resetLink = $urlGenerator->generate(
|
||||
'app_password_reset',
|
||||
['token' => $token],
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
// Envoyer un email de notification
|
||||
$email = (new Email())
|
||||
->from('contact@sortir.com')
|
||||
->to($participant->getEmail())
|
||||
->subject('Sortir.com | Bienvenue sur notre site !')
|
||||
->html("
|
||||
<h1>Bonjour $row[2],</h1>
|
||||
<p>Un administrateur du site vous a créé un compte !</p>
|
||||
<p>Terminer la création de cotre compte : <a href='$resetLink' target='_blank'>Sortir.com</a></p>
|
||||
<p>Toute l'équipe de Sortir vous souhaite la bienvenue !</p>
|
||||
");
|
||||
|
||||
$mailer->send($email);
|
||||
|
||||
}
|
||||
$em->flush();
|
||||
}
|
||||
@@ -216,9 +256,12 @@ class AdminController extends AbstractController
|
||||
|
||||
//Gestion des villes
|
||||
#[Route('/admin/city', name: 'app_adminCity')]
|
||||
public function adminCity(VilleRepository $villeRepository): Response
|
||||
public function adminCity(VilleRepository $villeRepository, TokenStorageInterface $tokenStorage): Response
|
||||
{
|
||||
$token = $tokenStorage->getToken();
|
||||
$userConnect = $token?->getUser();
|
||||
return $this->render('admin/city.html.twig', [
|
||||
'profile' => $userConnect,
|
||||
'citys' => $villeRepository->findAll(),
|
||||
'controller_name' => 'AdminController',
|
||||
]);
|
||||
@@ -275,9 +318,12 @@ class AdminController extends AbstractController
|
||||
|
||||
//Gestion des sites
|
||||
#[Route('/admin/site', name: 'app_adminSite')]
|
||||
public function adminSite(SiteRepository $siteRepository): Response
|
||||
public function adminSite(SiteRepository $siteRepository, TokenStorageInterface $tokenStorage): Response
|
||||
{
|
||||
$token = $tokenStorage->getToken();
|
||||
$userConnect = $token?->getUser();
|
||||
return $this->render('admin/site.html.twig', [
|
||||
'profile' => $userConnect,
|
||||
'sites' => $siteRepository->findAll(),
|
||||
'controller_name' => 'AdminController',
|
||||
]);
|
||||
|
||||
@@ -5,12 +5,17 @@ namespace App\Controller;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
class MainController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'home')]
|
||||
public function index(): Response
|
||||
public function index(TokenStorageInterface $tokenStorage): Response
|
||||
{
|
||||
return $this->render('main/index.html.twig');
|
||||
$token = $tokenStorage->getToken();
|
||||
$userConnect = $token?->getUser();
|
||||
return $this->render('main/index.html.twig', [
|
||||
'profile' => $userConnect,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +93,11 @@ class PasswordResetController extends AbstractController
|
||||
$newPassword = $request->request->get('password');
|
||||
$newPasswordConfirm = $request->request->get('passwordConfirm');
|
||||
|
||||
if ($newPassword.equalTo($newPasswordConfirm)) {
|
||||
// Vérifier si les mots de passe sont identiques
|
||||
if ($newPassword !== $newPasswordConfirm) {
|
||||
// Les mots de passe ne correspondent pas
|
||||
$this->addFlash('error', 'Les mots de passe ne correspondent pas.');
|
||||
return $this->redirectToRoute('app_password_reset', ['token' => $token]);
|
||||
return $this->redirectToRoute('app_password_reset'); // Vous pouvez rediriger vers la page de réinitialisation
|
||||
}
|
||||
|
||||
if (strlen($newPassword) < 6) {
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
<form action="{{ path('app_login') }}" method="post">
|
||||
<label class="text-gray-700 font-bold" for="username">Email ou pseudo</label>
|
||||
<input class="w-full mb-4 px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500" placeholder="Adresse e-mail ou pseudo" type="text" value="{{ last_username }}" name="username" id="username" autocomplete="email" required autofocus>
|
||||
<label class="text-gray-700 font-bold" for="password">Mot de passe</label>
|
||||
<input class="w-full mb-4 px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500" placeholder="Mot de passe" type="password" name="password" id="password" autocomplete="current-password" required>
|
||||
<div class="mb-4">
|
||||
<label class="text-gray-700 font-bold" for="password">Mot de passe</label>
|
||||
<input class="w-full mb-2 px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500" placeholder="Mot de passe" type="password" name="password" id="password" autocomplete="current-password" required>
|
||||
<a id="openModal" class="text-blue-500 text-sm hover:underline">Mot de passe oublié ?</a>
|
||||
</div>
|
||||
<label>
|
||||
<input type="checkbox" name="_remember_me" checked>
|
||||
Se souvenir de moi
|
||||
@@ -32,5 +35,38 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Modale pour ajouter une ville -->
|
||||
<div id="resetModal" 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">
|
||||
<h2 class="text-xl font-semibold mb-4">Mot de passe oublié ?</h2>
|
||||
<form id="resetForm" method="POST" action="{{ path('app_password_reset_request') }}">
|
||||
<div class="mb-4">
|
||||
<label for="email" class="block text-sm font-medium text-gray-700">Votre email</label>
|
||||
<input id="email" name="email" type="text" class="mt-1 block w-full px-4 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-700">Envoyer</button>
|
||||
<button type="button" id="closeModal" class="ml-2 bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-700">Annuler</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Ouvrir la modale
|
||||
document.getElementById('openModal').addEventListener('click', function() {
|
||||
document.getElementById('resetModal').classList.remove('hidden');
|
||||
});
|
||||
|
||||
// Fermer la modale
|
||||
document.getElementById('closeModal').addEventListener('click', function() {
|
||||
document.getElementById('resetModal').classList.add('hidden');
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -19,16 +19,25 @@
|
||||
</a>
|
||||
<!-- Liens de navigation -->
|
||||
<div class="relative">
|
||||
<button style="height:64px; width: 64px;" id="menu-button" class="p-2 pr-4 text-gray-700 font-bold hover:text-blue-500 focus:outline-none">
|
||||
<img alt="burger-menu" src="{{ asset('img/burger-menu.svg') }}">
|
||||
</button>
|
||||
{% if app.user %}
|
||||
<div id="menu-button" class="w-full flex justify-center">
|
||||
<div class="relative">
|
||||
<img src="{{ profile.fileName ? asset('upload/image/profile/' ~ profile.fileName) : asset('upload/image/profile/default.png') }}"
|
||||
class="w-16 h-16 rounded-full mr-4" />
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<button style="height:64px; width: 64px;" id="menu-button" class="p-2 pr-4 text-gray-700 font-bold hover:text-blue-500 focus:outline-none">
|
||||
<img alt="burger-menu" src="{{ asset('img/burger-menu.svg') }}">
|
||||
</button>
|
||||
{% endif %}
|
||||
<ul id="navbar" class="hidden absolute top-12 right-0 w-48 bg-white shadow-md p-4 flex-col space-y-4">
|
||||
<li><a href="{{ path('home') }}" class="text-gray-700 font-bold hover:text-blue-500">Accueil</a></li>
|
||||
{% if app.user %}
|
||||
<li><a href="{{ path('profile_view', {'uuid': app.user.idParticipant}) }}" class="text-gray-700 font-bold hover:text-blue-500">Mon profile</a></li>
|
||||
{% endif %}
|
||||
{% if app.user and ('ROLE_ADMIN' in app.user.roles) %}
|
||||
<li><a href="{{ path('app_adminUser') }}" class="text-gray-700 font-bold hover:text-blue-500">Administration</a></li>
|
||||
<li><a href="{{ path('app_admin') }}" class="text-gray-700 font-bold hover:text-blue-500">Administration</a></li>
|
||||
{% endif %}
|
||||
{% if app.user %}
|
||||
<li><a href="{{ path('app_logout') }}" class="text-gray-700 font-bold hover:text-blue-500">Se déconnecter</a></li>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<label class="text-gray-700 font-bold" for="password">Nouveau mot de passe</label>
|
||||
<input
|
||||
class="w-full mb-4 px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500"
|
||||
placeholder="Mot de passe" type="text" name="password" id="password" autocomplete="email" required autofocus>
|
||||
placeholder="Mot de passe" type="password" name="password" id="password" autocomplete="email" required autofocus>
|
||||
<label class="text-gray-700 font-bold" for="passwordConfirm">Confirmer votre nouveau mot de passe</label>
|
||||
<input class="w-full mb-4 px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500"
|
||||
placeholder="Confirmer votre mot de passe" type="password" name="passwordConfirm" id="passwordConfirm" required>
|
||||
|
||||
Reference in New Issue
Block a user