diff --git a/migrations/Version20211122102457.php b/migrations/Version20211122102457.php new file mode 100644 index 0000000000000000000000000000000000000000..5658e1248128b151840b2807f48c11882c30e1b2 --- /dev/null +++ b/migrations/Version20211122102457.php @@ -0,0 +1,31 @@ +<?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 Version20211122102457 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('ALTER TABLE user ADD $credential_expired TINYINT(1) NOT NULL, ADD enabled TINYINT(1) NOT NULL, ADD salt VARCHAR(255) NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE `user` DROP $credential_expired, DROP enabled, DROP salt'); + } +} diff --git a/src/Entity/User.php b/src/Entity/User.php index ad0e00349c7fce0564a1891b3877678e7df88125..6eeae4e93b0b0a340bbfcad3c959ed48615527ce 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -4,12 +4,14 @@ namespace App\Entity; use App\Repository\UserRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; /** * @ORM\Entity(repositoryClass=UserRepository::class) * @ORM\Table(name="`user`") + * @UniqueEntity(fields={"email"}, message="There is already an account with this email") */ class User implements UserInterface, PasswordAuthenticatedUserInterface { @@ -31,14 +33,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private $email_canonical; /** - * @ORM\Column(type="string") + * @ORM\Column(type="string", name="name") */ - private $name; + private $lastName; /** - * @ORM\Column(type="string") + * @ORM\Column(type="string", name="firstname") */ - private $firstname; + private $firstName; /** * @ORM\Column(type="string") @@ -50,6 +52,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface */ private $username_canonical; + /** + * @ORM\Column(type="boolean", name="$credential_expired") + */ + private $credentialExpired = false; + /** * @ORM\Column(type="json") */ @@ -61,6 +68,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface */ private $password; + /** + * @ORM\Column(type="boolean", name="enabled") + */ + private $isVerified = false; + + /** + * @ORM\Column(type="string", length=255, name="salt") + */ + private $salt; + public function getId(): ?int { return $this->id; @@ -74,7 +91,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface public function setEmail(string $email): self { $this->email = $email; - + $this->email_canonical = strtolower($email); + $this->username = $email; + $this->username_canonical = strtolower($email); return $this; } @@ -136,9 +155,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface * * @see UserInterface */ - public function getSalt(): ?string + public function getSalt(): string { - return null; + return $this->salt; } /** @@ -149,4 +168,56 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } + + public function isVerified(): bool + { + return $this->isVerified; + } + + public function setIsVerified(bool $isVerified): self + { + $this->isVerified = $isVerified; + + return $this; + } + + /** + * @return mixed + */ + public function getFirstName() : string + { + return $this->firstName; + } + + /** + * @return mixed + */ + public function getlastName() : ?string + { + return $this->lastName; + } + + /** + * @param mixed $firstName + */ + public function setFirstName(string $firstName): void + { + $this->firstName = $firstName; + } + + /** + * @param mixed $name + */ + public function setLastName(string $name): void + { + $this->lastName = $name; + } + + /** + * @param mixed $salt + */ + public function setSalt(string $salt): void + { + $this->salt = $salt; + } }