added UserNotVerifiedException

This commit is contained in:
tracer 2022-11-01 16:15:58 +01:00
parent d5b429da81
commit 3d4dec6299

View File

@ -0,0 +1,63 @@
<?php
namespace App\Exception;
use JetBrains\PhpStorm\ArrayShape;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use function is_array;
class UserNotVerifiedException extends AuthenticationException
{
private ?string $identifier = null;
/**
* {@inheritdoc}
*/
public function getMessageKey(): string
{
return 'User is not verified.';
}
/**
* Get the user identifier (e.g. username or email address).
*/
public function getUserIdentifier(): ?string
{
return $this->identifier;
}
/**
* Set the user identifier (e.g. username or email address).
*/
public function setUserIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
/**
* {@inheritdoc}
*/
#[ArrayShape(shape: ['{{ username }}' => "null|string", '{{ user_identifier }}' => "null|string"])]
public function getMessageData(): array
{
return ['{{ username }}' => $this->identifier, '{{ user_identifier }}' => $this->identifier];
}
/**
* {@inheritdoc}
*/
public function __serialize(): array
{
return [$this->identifier, parent::__serialize()];
}
/**
* {@inheritdoc}
*/
public function __unserialize(array $data): void
{
[$this->identifier, $parentData] = $data;
$parentData = is_array(value: $parentData) ? $parentData : unserialize(data: $parentData);
parent::__unserialize(data: $parentData);
}
}