diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..a32a582
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ postgresql
+ true
+ org.postgresql.Driver
+ jdbc:postgresql://172.20.96.1:5432/
+ $ProjectFileDir$
+
+
+ mariadb
+ true
+ org.mariadb.jdbc.Driver
+ jdbc:mariadb://127.0.0.1:3306/hegreconfort
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d042e16..6152663 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,8 +5,10 @@
-
+
+
+
@@ -167,13 +169,21 @@
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "develop",
- "last_opened_file_path": "C:/Users/serma/Desktop/HegreEtConfort",
+ "last_opened_file_path": "E:/BTS/PhpStorm/centre_fitness",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
+ "php.add.doc.comment.for.fields.panel.add.php.doc.for.all.properties": "true",
+ "settings.editor.selected.configurable": "inlay.hints",
"vue.rearranger.settings.migration": "true"
+ },
+ "keyToStringList": {
+ "DatabaseDriversLRU": [
+ "postgresql",
+ "mysql"
+ ]
}
}]]>
@@ -190,8 +200,8 @@
-
-
+
+
@@ -206,6 +216,7 @@
+
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 367af25..fbfb8ed 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -4,14 +4,18 @@ security:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
- users_in_memory: { memory: null }
+ # used to reload user from session & other features (e.g. switch_user)
+ app_user_provider:
+ entity:
+ class: App\Entity\User
+ property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
- provider: users_in_memory
+ provider: app_user_provider
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
diff --git a/migrations/Version20241114151456.php b/migrations/Version20241114151456.php
new file mode 100644
index 0000000..34acab8
--- /dev/null
+++ b/migrations/Version20241114151456.php
@@ -0,0 +1,43 @@
+addSql('CREATE TABLE fault (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE intervention (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, timestamp DATETIME NOT NULL, description VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE skill (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE stock (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, quantity VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE `user` (id INT AUTO_INCREMENT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birth_date DATE NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE vehicle (id INT AUTO_INCREMENT NOT NULL, license_plate VARCHAR(255) NOT NULL, brand VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ }
+
+ public function down(Schema $schema): void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('DROP TABLE fault');
+ $this->addSql('DROP TABLE intervention');
+ $this->addSql('DROP TABLE skill');
+ $this->addSql('DROP TABLE stock');
+ $this->addSql('DROP TABLE `user`');
+ $this->addSql('DROP TABLE vehicle');
+ $this->addSql('DROP TABLE messenger_messages');
+ }
+}
diff --git a/src/Entity/User.php b/src/Entity/User.php
index 3a2f4d1..0be20f0 100644
--- a/src/Entity/User.php
+++ b/src/Entity/User.php
@@ -5,16 +5,21 @@ namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
+use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
-#[ORM\Table(name: '`user`')]
-class User
+#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
+class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
+ #[ORM\Column(length: 180)]
+ private ?string $email = null;
+
#[ORM\Column(length: 255)]
private ?string $FirstName = null;
@@ -29,84 +34,154 @@ class User
#[ORM\Column(length: 255)]
private ?string $Phone = null;
+ /**
+ * @var list The user roles
+ */
+ #[ORM\Column]
+ private array $roles = [];
- #[ORM\Column(length: 255)]
- private ?string $Type = null;
+ /**
+ * @var string The hashed password
+ */
+ #[ORM\Column]
+ private ?string $password = null;
public function getId(): ?int
{
return $this->id;
}
- public function getFirstName(): ?string
- {
- return $this->FirstName;
- }
-
- public function setFirstName(string $FirstName): static
- {
- $this->FirstName = $FirstName;
-
- return $this;
- }
-
- public function getLastName(): ?string
- {
- return $this->LastName;
- }
-
- public function setLastName(string $LastName): static
- {
- $this->LastName = $LastName;
-
- return $this;
- }
-
+ /**
+ * @return \DateTimeInterface|null
+ */
public function getBirthDate(): ?\DateTimeInterface
{
return $this->BirthDate;
}
- public function setBirthDate(\DateTimeInterface $BirthDate): static
+ /**
+ * @param \DateTimeInterface|null $BirthDate
+ */
+ public function setBirthDate(?\DateTimeInterface $BirthDate): void
{
$this->BirthDate = $BirthDate;
-
- return $this;
}
- public function getEmail(): ?string
+ /**
+ * @return string|null
+ */
+ public function getLastName(): ?string
{
- return $this->Email;
+ return $this->LastName;
}
- public function setEmail(string $Email): static
+ /**
+ * @param string|null $LastName
+ */
+ public function setLastName(?string $LastName): void
{
- $this->Email = $Email;
-
- return $this;
+ $this->LastName = $LastName;
}
+ /**
+ * @return string|null
+ */
+ public function getFirstName(): ?string
+ {
+ return $this->FirstName;
+ }
+
+ /**
+ * @param string|null $FirstName
+ */
+ public function setFirstName(?string $FirstName): void
+ {
+ $this->FirstName = $FirstName;
+ }
+
+ /**
+ * @return string|null
+ */
public function getPhone(): ?string
{
return $this->Phone;
}
- public function setPhone(string $Phone): static
+ /**
+ * @param string|null $Phone
+ */
+ public function setPhone(?string $Phone): void
{
$this->Phone = $Phone;
+ }
+
+ public function getEmail(): ?string
+ {
+ return $this->email;
+ }
+
+ public function setEmail(string $email): static
+ {
+ $this->email = $email;
return $this;
}
- public function getType(): ?string
+ /**
+ * A visual identifier that represents this user.
+ *
+ * @see UserInterface
+ */
+ public function getUserIdentifier(): string
{
- return $this->Type;
+ return (string) $this->email;
}
- public function setType(string $Type): static
+ /**
+ * @see UserInterface
+ *
+ * @return list
+ */
+ public function getRoles(): array
{
- $this->Type = $Type;
+ $roles = $this->roles;
+ // guarantee every user at least has ROLE_USER
+ $roles[] = 'ROLE_USER';
+
+ return array_unique($roles);
+ }
+
+ /**
+ * @param list $roles
+ */
+ public function setRoles(array $roles): static
+ {
+ $this->roles = $roles;
return $this;
}
+
+ /**
+ * @see PasswordAuthenticatedUserInterface
+ */
+ public function getPassword(): ?string
+ {
+ return $this->password;
+ }
+
+ public function setPassword(string $password): static
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * @see UserInterface
+ */
+ public function eraseCredentials(): void
+ {
+ // If you store any temporary, sensitive data on the user, clear it here
+ // $this->plainPassword = null;
+ }
}
diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php
index b29153b..4f2804e 100644
--- a/src/Repository/UserRepository.php
+++ b/src/Repository/UserRepository.php
@@ -5,17 +5,34 @@ namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
+use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
+use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
+use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
/**
* @extends ServiceEntityRepository
*/
-class UserRepository extends ServiceEntityRepository
+class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
+ /**
+ * Used to upgrade (rehash) the user's password automatically over time.
+ */
+ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
+ {
+ if (!$user instanceof User) {
+ throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
+ }
+
+ $user->setPassword($newHashedPassword);
+ $this->getEntityManager()->persist($user);
+ $this->getEntityManager()->flush();
+ }
+
// /**
// * @return User[] Returns an array of User objects
// */