Files
myep/src/Entity/User.php
T
Björn Fromme c582e0820a feat: move profile completeness check from login to booking flow entry
- Add profileComplete flag to User entity to avoid API calls
- Set flag during login (BpnAuthenticator) and profile save
- Check flag in IndexController when entering booking flow
- Remove ProfileCompletionSubscriber (no longer needed)

Users with incomplete profiles are only redirected when starting
a new booking, not on every login. Eliminates extra API call by
caching completeness status on the user entity.
2026-03-16 12:02:59 +01:00

156 lines
3.1 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 180, unique: true)]
private ?string $email;
#[ORM\Column(type: 'text')]
private ?string $password = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $personId = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $addressId = null;
#[ORM\Column(type: 'json')]
private array $roles = [];
#[ORM\Column(type: 'json')]
private array $hotelCodes = [];
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $lastLoginAt = null;
#[ORM\Column(type: 'boolean')]
private bool $profileComplete = false;
public function __construct(string $email)
{
$this->email = $email;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
$this->email = $email;
return $this;
}
public function getPersonId(): ?int
{
return $this->personId;
}
public function setPersonId(?int $personId): static
{
$this->personId = $personId;
return $this;
}
public function getAddressId(): ?int
{
return $this->addressId;
}
public function setAddressId(?int $addressId): static
{
$this->addressId = $addressId;
return $this;
}
public function getPassword(): ?string
{
return base64_decode($this->password);
}
public function setPassword(?string $password): static
{
$this->password = base64_encode($password);
return $this;
}
public function getRoles(): array
{
return ['ROLE_USER', ...$this->roles];
}
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
public function getHotelCodes(): array
{
return $this->hotelCodes;
}
public function setHotelCodes(array $hotelCodes): static
{
$this->hotelCodes = $hotelCodes;
return $this;
}
public function getLastLoginAt(): ?\DateTimeImmutable
{
return $this->lastLoginAt;
}
public function setLastLoginAt(?\DateTimeImmutable $lastLoginAt): static
{
$this->lastLoginAt = $lastLoginAt;
return $this;
}
public function isProfileComplete(): bool
{
return $this->profileComplete;
}
public function setProfileComplete(bool $profileComplete): static
{
$this->profileComplete = $profileComplete;
return $this;
}
public function eraseCredentials(): void
{
}
public function getUserIdentifier(): string
{
return $this->email;
}
}