*/ #[ORM\Column(type: 'json')] private array $roles = []; /** * @var string The hashed password */ #[ORM\Column(type: 'string')] private string $password = ''; #[ORM\Column(type: 'string', length: 120, nullable: true)] #[Assert\Length(max: 120)] private ?string $displayName = null; #[ORM\Column(type: 'string', length: 255, nullable: true)] private ?string $profileImagePath = null; #[ORM\Column(type: 'string', length: 50, nullable: true)] private ?string $oauthProvider = null; #[ORM\Column(type: 'string', length: 190, nullable: true)] private ?string $oauthId = null; /** * Returns the database identifier. */ public function getId(): ?int { return $this->id; } /** * Returns the normalized email address. */ public function getEmail(): string { return $this->email; } /** * Sets and normalizes the email address. */ public function setEmail(string $email): void { $this->email = strtolower($email); } /** * Symfony security identifier alias for the email. */ public function getUserIdentifier(): string { return $this->email; } /** * Returns the unique role list plus the implicit ROLE_USER. * * @return list */ public function getRoles(): array { $roles = $this->roles; if (!in_array('ROLE_USER', $roles, true)) { $roles[] = 'ROLE_USER'; } return array_values(array_unique($roles)); } /** * Replaces the granted role list. * * @param list $roles */ public function setRoles(array $roles): void { $this->roles = array_values(array_unique($roles)); } /** * Adds a single role if not already present. */ public function addRole(string $role): void { $roles = $this->getRoles(); if (!in_array($role, $roles, true)) { $roles[] = $role; } $this->roles = $roles; } /** * Returns the hashed password string. */ public function getPassword(): string { return $this->password; } /** * Stores the hashed password string. */ public function setPassword(string $hashedPassword): void { $this->password = $hashedPassword; } /** * Removes any sensitive transient data (no-op here). */ #[\Deprecated(reason: 'No transient credentials stored; method retained for BC.')] public function eraseCredentials(): void { // no-op } /** * Returns the optional display name. */ public function getDisplayName(): ?string { return $this->displayName; } /** * Sets the optional display name. */ public function setDisplayName(?string $displayName): void { $this->displayName = $displayName; } public function getProfileImagePath(): ?string { return $this->profileImagePath; } public function setProfileImagePath(?string $profileImagePath): void { $this->profileImagePath = $profileImagePath; } public function getOauthProvider(): ?string { return $this->oauthProvider; } public function setOauthProvider(?string $oauthProvider): void { $this->oauthProvider = $oauthProvider === null ? null : strtolower(trim($oauthProvider)); } public function getOauthId(): ?string { return $this->oauthId; } public function setOauthId(?string $oauthId): void { $this->oauthId = $oauthId === null ? null : trim($oauthId); } }