login plus propre, sans erreur à finir car il ne se connect pas

This commit is contained in:
sermandm 2025-04-10 16:43:20 +02:00
parent 665589a395
commit 39c6623e3d
10 changed files with 104 additions and 104 deletions

12
.idea/dataSources.xml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="HegreEtConfort@localhost" uuid="21423ae4-3232-4641-affb-06399f70655a">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5433/HegreEtConfort</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -7,7 +7,7 @@ security:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: App\Entity\User
class: App\Entity\Utilisateur
property: email
firewalls:
dev:
@ -17,6 +17,7 @@ security:
lazy: true
provider: app_user_provider
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
@ -26,8 +27,8 @@ security:
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/profile, roles: ROLE_USER }
when@test:
security:

View File

@ -1,50 +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 Version20241205162005 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 SEQUENCE fault_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE intervention_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE stock_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE user_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE vehicle_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('ALTER TABLE "user" ADD roles JSON NOT NULL');
$this->addSql('ALTER TABLE "user" ALTER email TYPE VARCHAR(180)');
$this->addSql('ALTER TABLE "user" RENAME COLUMN type TO password');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON "user" (email)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE fault_id_seq CASCADE');
$this->addSql('DROP SEQUENCE intervention_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('DROP SEQUENCE stock_id_seq CASCADE');
$this->addSql('DROP SEQUENCE user_id_seq CASCADE');
$this->addSql('DROP SEQUENCE vehicle_id_seq CASCADE');
$this->addSql('DROP INDEX UNIQ_IDENTIFIER_EMAIL');
$this->addSql('ALTER TABLE "user" DROP roles');
$this->addSql('ALTER TABLE "user" ALTER email TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE "user" RENAME COLUMN password TO type');
}
}

View File

@ -1,31 +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 Version20241212153452 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
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
}
}

View File

@ -0,0 +1,71 @@
<?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 Version20250410124208 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 SEQUENCE fault_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE intervention_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE stock_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE utilisateur_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE vehicle_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE fault (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE intervention (id INT NOT NULL, wording VARCHAR(255) NOT NULL, timestamp TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, description VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE skill (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE stock (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, quantity VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE utilisateur (id INT NOT NULL, email VARCHAR(180) NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birth_date DATE NOT NULL, phone VARCHAR(255) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON utilisateur (email)');
$this->addSql('CREATE TABLE vehicle (id INT NOT NULL, license_plate VARCHAR(255) NOT NULL, brand VARCHAR(255) NOT NULL, model VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
$this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
BEGIN
PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;');
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE fault_id_seq CASCADE');
$this->addSql('DROP SEQUENCE intervention_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('DROP SEQUENCE stock_id_seq CASCADE');
$this->addSql('DROP SEQUENCE utilisateur_id_seq CASCADE');
$this->addSql('DROP SEQUENCE vehicle_id_seq CASCADE');
$this->addSql('DROP TABLE fault');
$this->addSql('DROP TABLE intervention');
$this->addSql('DROP TABLE skill');
$this->addSql('DROP TABLE stock');
$this->addSql('DROP TABLE utilisateur');
$this->addSql('DROP TABLE vehicle');
$this->addSql('DROP TABLE messenger_messages');
}
}

View File

@ -2,7 +2,7 @@
namespace App\Controller;
use App\Entity\User;
use App\Entity\Utilisateur;
use App\Form\UserType;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
@ -25,7 +25,7 @@ final class UserController extends AbstractController
#[Route('/new', name: 'app_user_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$user = new User();
$user = new Utilisateur();
$form = $this->createForm(UserType::class, $user);
$form->handleRequest($request);
@ -43,7 +43,7 @@ final class UserController extends AbstractController
}
#[Route('/{id}', name: 'app_user_show', methods: ['GET'])]
public function show(User $user): Response
public function show(Utilisateur $user): Response
{
return $this->render('user/show.html.twig', [
'user' => $user,
@ -51,7 +51,7 @@ final class UserController extends AbstractController
}
#[Route('/{id}/edit', name: 'app_user_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, User $user, EntityManagerInterface $entityManager): Response
public function edit(Request $request, Utilisateur $user, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(UserType::class, $user);
$form->handleRequest($request);
@ -69,7 +69,7 @@ final class UserController extends AbstractController
}
#[Route('/{id}', name: 'app_user_delete', methods: ['POST'])]
public function delete(Request $request, User $user, EntityManagerInterface $entityManager): Response
public function delete(Request $request, Utilisateur $user, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->getPayload()->getString('_token'))) {
$entityManager->remove($user);

View File

@ -10,7 +10,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
class User implements UserInterface, PasswordAuthenticatedUserInterface
class Utilisateur implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]

View File

@ -2,7 +2,7 @@
namespace App\Form;
use App\Entity\User;
use App\Entity\Utilisateur;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
@ -32,7 +32,7 @@ class UserType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
'data_class' => Utilisateur::class,
]);
}
}

View File

@ -2,7 +2,7 @@
namespace App\Repository;
use App\Entity\User;
use App\Entity\Utilisateur;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
@ -10,13 +10,13 @@ use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
/**
* @extends ServiceEntityRepository<User>
* @extends ServiceEntityRepository<Utilisateur>
*/
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
parent::__construct($registry, Utilisateur::class);
}
/**
@ -24,7 +24,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
*/
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
{
if (!$user instanceof User) {
if (!$user instanceof Utilisateur) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}
@ -34,7 +34,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
}
// /**
// * @return User[] Returns an array of User objects
// * @return Utilisateur[] Returns an array of Utilisateur objects
// */
// public function findByExampleField($value): array
// {
@ -48,7 +48,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
// ;
// }
// public function findOneBySomeField($value): ?User
// public function findOneBySomeField($value): ?Utilisateur
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')

View File

@ -40,14 +40,11 @@
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
<input type="checkbox" name="remember" id="remember">
<label class="remember" for="remember">Se souvenir de moi</label>
</label>
<button type="submit" class="login"> Connexion </button>
</form>
<button class="login"> Connexion </button>
<p class="forgot"> Mot de passe oublié ?</p>
</section>
</div>
</body>