‪TYPO3CMS  ‪main
MfaVerificationErrorOccurredMessage.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\UriInterface;
24 
28 #[WebhookMessage(
29  identifier: 'typo3/mfa-error',
30  ‪description: 'LLL:EXT:webhooks/Resources/Private/Language/locallang_db.xlf:sys_webhook.webhook_type.typo3-mfa-error'
31 )]
32 final class MfaVerificationErrorOccurredMessage implements ‪WebhookMessageInterface
33 {
34  public function __construct(
35  private readonly bool $isFrontend,
36  private readonly UriInterface ‪$url,
37  private readonly array ‪$details,
38  ) {}
39 
40  public function jsonSerialize(): array
41  {
42  return [
43  'context' => $this->isFrontend ? 'frontend' : 'backend',
44  'url' => (string)$this->url,
45  'details' => $this->details,
46  ];
47  }
48 
49  public static function createFromEvent(MfaVerificationFailedEvent $event): self
50  {
51  $user = $event->getUser();
52 
53  return new self(
54  $event->isFrontendAttempt(),
55  $event->getRequest()->getUri(),
56  [
57  'user' => [
58  'id' => $user->user[$user->userid_column],
59  'name' => $user->user[$user->username_column],
60  ],
61  'provider' => $event->getProviderIdentifier(),
62  'isLocked' => $event->isProviderLocked(),
63  ]
64  );
65  }
66 }
‪TYPO3\CMS\Webhooks\Message\$details
‪identifier readonly UriInterface readonly array $details
Definition: MfaVerificationErrorOccurredMessage.php:37
‪TYPO3\CMS\Core\Attribute\WebhookMessage
Definition: WebhookMessage.php:25
‪TYPO3\CMS\Webhooks\Message
Definition: FileAddedMessage.php:18
‪TYPO3\CMS\Core\Authentication\Event\MfaVerificationFailedEvent
Definition: MfaVerificationFailedEvent.php:29
‪TYPO3\CMS\Core\Messaging\WebhookMessageInterface
Definition: WebhookMessageInterface.php:28
‪TYPO3\CMS\Webhooks\Message\description
‪identifier description
Definition: FileAddedMessage.php:36
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36