Skip to content
Snippets Groups Projects
Commit eef8cbcf authored by Sebastien Curt's avatar Sebastien Curt
Browse files

set User compatible to the production database

parent e6acd9ac
Branches
Tags
1 merge request!8Tuleap 40 register
<?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');
}
}
...@@ -4,12 +4,14 @@ namespace App\Entity; ...@@ -4,12 +4,14 @@ namespace App\Entity;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM; 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\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
/** /**
* @ORM\Entity(repositoryClass=UserRepository::class) * @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`user`") * @ORM\Table(name="`user`")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/ */
class User implements UserInterface, PasswordAuthenticatedUserInterface class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
...@@ -31,14 +33,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ...@@ -31,14 +33,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private $email_canonical; 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") * @ORM\Column(type="string")
...@@ -50,6 +52,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ...@@ -50,6 +52,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
*/ */
private $username_canonical; private $username_canonical;
/**
* @ORM\Column(type="boolean", name="$credential_expired")
*/
private $credentialExpired = false;
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
*/ */
...@@ -61,6 +68,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ...@@ -61,6 +68,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
*/ */
private $password; 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 public function getId(): ?int
{ {
return $this->id; return $this->id;
...@@ -74,7 +91,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ...@@ -74,7 +91,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
public function setEmail(string $email): self public function setEmail(string $email): self
{ {
$this->email = $email; $this->email = $email;
$this->email_canonical = strtolower($email);
$this->username = $email;
$this->username_canonical = strtolower($email);
return $this; return $this;
} }
...@@ -136,9 +155,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ...@@ -136,9 +155,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
* *
* @see UserInterface * @see UserInterface
*/ */
public function getSalt(): ?string public function getSalt(): string
{ {
return null; return $this->salt;
} }
/** /**
...@@ -149,4 +168,56 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ...@@ -149,4 +168,56 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
// If you store any temporary, sensitive data on the user, clear it here // If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null; // $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;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment