src/App/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Company\Person;
  4. use App\Entity\Traits\Creation;
  5. use App\Entity\Traits\Idable;
  6. use App\Repository\UserRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. #[ORM\Entity(repositoryClassUserRepository::class)]
  12. #[ORM\Table(name'users')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterfaceTwoFactorInterface
  14. {
  15.     use Idable;
  16.     use Creation;
  17.     #[ORM\OneToOne(targetEntityPerson::class, mappedBy'relatedUser')]
  18.     protected $person;
  19.     #[ORM\Column(type'string'length180uniquetrue)]
  20.     protected $email;
  21.     #[ORM\Column(type'string'length50)]
  22.     protected $name;
  23.     #[ORM\Column(type'string'length50)]
  24.     protected $surname;
  25.     #[ORM\Column(type'string'length100)]
  26.     protected $fullName;
  27.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'users')]
  28.     protected $company;
  29.     #[ORM\Column(type'boolean'nullabletrueoptions: ['default' => 1])]
  30.     protected $isActive;
  31.     #[ORM\Column(type'json')]
  32.     protected $roles = [];
  33.     #[ORM\Column(type'boolean'nullabletrueoptions: ['default' => 0])]
  34.     protected $isBackOfficeUser;
  35.     #[ORM\Column(type'string')]
  36.     protected $password;
  37.     #[ORM\Column(type'string'nullabletrue)]
  38.     protected ?string $authCode;
  39.     #[ORM\Column(type'boolean'nullabletrueoptions: ['default' => 1])]
  40.     protected $tempPassword;
  41.     #[ORM\Column(type'string'nullabletrueoptions: ['default' => null])]
  42.     protected $googleAuthId;
  43.     #[ORM\Column(type'string'nullabletrue)]
  44.     protected $uid;
  45.     #[ORM\Column(type'datetime'nullabletrue)]
  46.     protected $forgotPasswordCreatedTime;
  47.     #[ORM\Column(type'datetime'nullabletrue)]
  48.     protected $forgotPasswordUpdatedTime;
  49.     /**
  50.      * @return mixed
  51.      */
  52.     public function getUid()
  53.     {
  54.         return $this->uid;
  55.     }
  56.     /**
  57.      * @param mixed $uid
  58.      */
  59.     public function setUid($uid): void
  60.     {
  61.         $this->uid $uid;
  62.     }
  63.     public function getEmail(): ?string
  64.     {
  65.         return $this->email;
  66.     }
  67.     public function getAuthCode(): ?string
  68.     {
  69.         return $this->authCode;
  70.     }
  71.     public function setAuthCode(?string $authCode): void
  72.     {
  73.         $this->authCode $authCode;
  74.     }
  75.     /**
  76.      * @return mixed
  77.      */
  78.     public function getTempPassword()
  79.     {
  80.         return $this->tempPassword;
  81.     }
  82.     /**
  83.      * @param mixed $tempPassword
  84.      */
  85.     public function setTempPassword($tempPassword): void
  86.     {
  87.         $this->tempPassword $tempPassword;
  88.     }
  89.     public function setEmail(string $email): self
  90.     {
  91.         $this->email $email;
  92.         return $this;
  93.     }
  94.     /**
  95.      * A visual identifier that represents this user.
  96.      *
  97.      * @see UserInterface
  98.      */
  99.     public function getUserIdentifier(): string
  100.     {
  101.         return (string) $this->email;
  102.     }
  103.     /**
  104.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  105.      */
  106.     public function getUsername(): string
  107.     {
  108.         return (string) $this->email;
  109.     }
  110.     /**
  111.      * @see UserInterface
  112.      */
  113.     public function getRoles(): array
  114.     {
  115.         $roles $this->roles;
  116.         return array_unique($roles);
  117.     }
  118.     public function setRoles(array $roles): self
  119.     {
  120.         $this->roles $roles;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return mixed
  125.      */
  126.     public function getIsBackOfficeUser()
  127.     {
  128.         return $this->isBackOfficeUser;
  129.     }
  130.     /**
  131.      * @param mixed $isBackOfficeUser
  132.      */
  133.     public function setIsBackOfficeUser($isBackOfficeUser): void
  134.     {
  135.         $this->isBackOfficeUser $isBackOfficeUser;
  136.     }
  137.     /**
  138.      * @see PasswordAuthenticatedUserInterface
  139.      */
  140.     public function getPassword(): string
  141.     {
  142.         return $this->password;
  143.     }
  144.     public function setPassword(string $password): self
  145.     {
  146.         $this->password $password;
  147.         return $this;
  148.     }
  149.     /**
  150.      * Returning a salt is only needed, if you are not using a modern
  151.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  152.      *
  153.      * @see UserInterface
  154.      */
  155.     public function getSalt(): ?string
  156.     {
  157.         return null;
  158.     }
  159.     /**
  160.      * @see UserInterface
  161.      */
  162.     public function eraseCredentials()
  163.     {
  164.         // If you store any temporary, sensitive data on the user, clear it here
  165.         // $this->plainPassword = null;
  166.     }
  167.     /**
  168.      * @return mixed
  169.      */
  170.     public function getName()
  171.     {
  172.         return $this->name;
  173.     }
  174.     /**
  175.      * @param mixed $name
  176.      */
  177.     public function setName($name): void
  178.     {
  179.         $this->name $name;
  180.     }
  181.     /**
  182.      * @return mixed
  183.      */
  184.     public function getSurname()
  185.     {
  186.         return $this->surname;
  187.     }
  188.     /**
  189.      * @param mixed $surname
  190.      */
  191.     public function setSurname($surname): void
  192.     {
  193.         $this->surname $surname;
  194.     }
  195.     /**
  196.      * @return mixed
  197.      */
  198.     public function getFullName()
  199.     {
  200.         return $this->fullName;
  201.     }
  202.     /**
  203.      * @param mixed $fullName
  204.      */
  205.     public function setFullName($fullName): void
  206.     {
  207.         $this->fullName $fullName;
  208.     }
  209.     public function getCompany(): ?Company
  210.     {
  211.         return $this->company;
  212.     }
  213.     public function setCompany(?Company $company): self
  214.     {
  215.         $this->company $company;
  216.         return $this;
  217.     }
  218.     /**
  219.      * @return mixed
  220.      */
  221.     public function getIsActive()
  222.     {
  223.         return $this->isActive;
  224.     }
  225.     /**
  226.      * @param mixed $isActive
  227.      */
  228.     public function setIsActive($isActive): void
  229.     {
  230.         $this->isActive $isActive;
  231.     }
  232.     /**
  233.      * @return Person
  234.      */
  235.     public function getPerson()
  236.     {
  237.         return $this->person;
  238.     }
  239.     public function isEmailAuthEnabled(): bool
  240.     {
  241.         return true// This can be a persisted field to switch email code authentication on/off
  242.     }
  243.     public function getEmailAuthRecipient(): string
  244.     {
  245.         return $this->email;
  246.     }
  247.     public function getEmailAuthCode(): string
  248.     {
  249.         if (null === $this->authCode) {
  250.             throw new \LogicException('The email authentication code was not set');
  251.         }
  252.         return $this->authCode;
  253.     }
  254.     public function setEmailAuthCode(string $authCode): void
  255.     {
  256.         $this->authCode $authCode;
  257.     }
  258.     /**
  259.      * @return mixed
  260.      */
  261.     public function getGoogleAuthId()
  262.     {
  263.         return $this->googleAuthId;
  264.     }
  265.     /**
  266.      * @param mixed $googleAuthId
  267.      */
  268.     public function setGoogleAuthId($googleAuthId): void
  269.     {
  270.         $this->googleAuthId $googleAuthId;
  271.     }
  272.     /**
  273.      * @return mixed
  274.      */
  275.     public function getForgotPasswordCreatedTime()
  276.     {
  277.         return $this->forgotPasswordCreatedTime;
  278.     }
  279.     /**
  280.      * @param mixed $forgotPasswordCreatedTime
  281.      */
  282.     public function setForgotPasswordCreatedTime($forgotPasswordCreatedTime): void
  283.     {
  284.         $this->forgotPasswordCreatedTime $forgotPasswordCreatedTime;
  285.     }
  286.     /**
  287.      * @return mixed
  288.      */
  289.     public function getForgotPasswordUpdatedTime()
  290.     {
  291.         return $this->forgotPasswordUpdatedTime;
  292.     }
  293.     /**
  294.      * @param mixed $forgotPasswordUpdatedTime
  295.      */
  296.     public function setForgotPasswordUpdatedTime($forgotPasswordUpdatedTime): void
  297.     {
  298.         $this->forgotPasswordUpdatedTime $forgotPasswordUpdatedTime;
  299.     }
  300. }