Skip to content
Snippets Groups Projects
Select Git revision
  • 944a650750c2c323888a149f72bc58fb5102f7b5
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

CapsuleRepository.php

Blame
  • User.php 4.59 KiB
    <?php
    
    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\LegacyPasswordAuthenticatedUserInterface;
    use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
    use Symfony\Component\Security\Core\User\UserInterface;
    use Symfony\Component\Validator\Constraints as Assert;
    
    /**
     * @ORM\Entity(repositoryClass=UserRepository::class)
     * @ORM\Table(name="`user`")
     * @UniqueEntity(fields={"email"}, message="email.unique")
     */
    class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
    {
        /**
         * @ORM\Id
         * @ORM\GeneratedValue
         * @ORM\Column(type="integer")
         */
        private int $id;
    
        /**
         * @ORM\Column(type="string", length=255)
         * @Assert\Email(message = "The email {{ value }} is not a valid email.")
         */
        private string $email;
    
        /**
         * @ORM\Column(type="string", length=255, unique=true)
         */
        private string $email_canonical;
    
        /**
         * @ORM\Column(type="string", name="name")
         */
        private string $lastName;
    
        /**
         * @ORM\Column(type="string", name="firstname")
         */
        private string $firstName;
    
        /**
         * @ORM\Column(type="string")
         */
        private string $username;
    
        /**
         * @ORM\Column(type="string", name="username_canonical", unique=true)
         */
        private string $username_canonical;
    
        /**
         * @ORM\Column(type="boolean", name="credential_expired")
         */
        private bool $credentialExpired = false;
    
        /**
         * @ORM\Column(type="json")
         */
        /** @phpstan-ignore-next-line */
        private array $roles = [];
    
        /**
         * @var string The hashed password
         * @ORM\Column(type="string")
         */
        private string $password;
    
        /**
         * @ORM\Column(type="boolean", name="enabled")
         */
        private bool $isVerified = false;
    
        /**
         * @ORM\Column(type="string", length=255, name="salt")
         */
        private string $salt;
    
        public function getId(): ?int
        {
            return $this->id;
        }
    
        public function getEmail(): string
        {
            return $this->email;
        }
    
        public function setEmail(string $email): self
        {
            $this->email = $email;
            $this->email_canonical = strtolower($email);
            $this->username = $email;
            $this->username_canonical = strtolower($email);
            return $this;
        }
    
        /**
         * A visual identifier that represents this user.
         *
         * @see UserInterface
         */
        public function getUserIdentifier(): string
        {
            return (string) $this->email;
        }
    
        /**
         * @deprecated since Symfony 5.3, use getUserIdentifier instead
         */
        public function getUsername(): string
        {
            return $this->email;
        }
    
        /**
         * @see UserInterface
         */
        public function getRoles(): array
        {
            $roles = $this->roles;
            // guarantee every user at least has ROLE_USER
            $roles[] = 'ROLE_USER';
    
            return array_unique($roles);
        }
    
        /**
         * @param array<string> $roles
         */
        public function setRoles(array $roles): self
        {
            $this->roles = $roles;
    
            return $this;
        }
    
        /**
         * @see PasswordAuthenticatedUserInterface
         */
        public function getPassword(): string
        {
            return $this->password;
        }
    
        public function setPassword(string $password): self
        {
            $this->password = $password;
    
            return $this;
        }
    
        /**
         * Returning a salt is only needed, if you are not using a modern
         * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
         *
         * @see UserInterface
         */
        public function getSalt(): string
        {
            return $this->salt;
        }
    
        /**
         * @see UserInterface
         */
        public function eraseCredentials(): void
        {
            // 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;
        }
    
        public function getFirstName(): string
        {
            return $this->firstName;
        }
    
        public function getLastName(): ?string
        {
            return $this->lastName;
        }
    
        public function setFirstName(string $firstName): void
        {
            $this->firstName = $firstName;
        }
    
        public function setLastName(string $name): void
        {
            $this->lastName = $name;
        }
    
        public function setSalt(string $salt): void
        {
            $this->salt = $salt;
        }
    }