<?php
declare(strict_types=1);
namespace App\Entity\User;
use Arobases\SyliusRightsManagementPlugin\Entity\AdminUserInterface;
use Arobases\SyliusRightsManagementPlugin\Entity\AdminUserTrait;
use Doctrine\ORM\Mapping as ORM;
use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
use Sylius\Component\Core\Model\AdminUser as BaseAdminUser;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_admin_user")
*
* @method string getUserIdentifier()
*/
class AdminUser extends BaseAdminUser implements AdminUserInterface, TwoFactorInterface
{
use AdminUserTrait;
/** @ORM\Column(type="string", nullable=true) */
private ?string $authCode;
// [...]
public function isEmailAuthEnabled(): bool
{
return true; // This can be a persisted field to switch email code authentication on/off
}
public function getEmailAuthRecipient(): string
{
return $this->email;
}
public function getEmailAuthCode(): string
{
if (null === $this->authCode) {
throw new \LogicException('The email authentication code was not set');
}
return $this->authCode;
}
public function setEmailAuthCode(string $authCode): void
{
$this->authCode = $authCode;
}
}