From 3d4dec6299c0a8381b72043af1606b0623da81a8 Mon Sep 17 00:00:00 2001
From: tracer <tracer@24unix.net>
Date: Tue, 1 Nov 2022 16:15:58 +0100
Subject: [PATCH] added UserNotVerifiedException

---
 src/Exception/UserNotVerifiedException.php | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 src/Exception/UserNotVerifiedException.php

diff --git a/src/Exception/UserNotVerifiedException.php b/src/Exception/UserNotVerifiedException.php
new file mode 100644
index 0000000..afc4460
--- /dev/null
+++ b/src/Exception/UserNotVerifiedException.php
@@ -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);
+    }
+}