-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Dispatch event after BE user's password reset (#5108)
* [FEATURE] Dispatch event after BE user's password reset Resolves: TYPO3-Documentation/Changelog-To-Doc#1166 Releases: main * Apply suggestions from code review Co-authored-by: Stefan Frömken <froemken@gmail.com> --------- Co-authored-by: Stefan Frömken <froemken@gmail.com>
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Documentation/ApiOverview/Events/Events/Backend/PasswordHasBeenResetEvent.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. include:: /Includes.rst.txt | ||
.. index:: Events; PasswordHasBeenResetEvent | ||
.. _PasswordHasBeenResetEvent: | ||
|
||
========================= | ||
PasswordHasBeenResetEvent | ||
========================= | ||
|
||
.. versionadded:: 14.0 | ||
It is possible to add custom business logic after a Backend user resets their | ||
password using the new PSR-14 event. | ||
|
||
The event :php-short:`\TYPO3\CMS\Backend\Authentication\Event\PasswordHasBeenResetEvent` | ||
is raised right after a backend user resets their password | ||
and it has been hashed and persisted to the database. | ||
|
||
The event contains the corresponding backend user UID. | ||
|
||
.. _PasswordHasBeenResetEvent-example: | ||
|
||
Example | ||
======= | ||
|
||
The corresponding event listener class: | ||
|
||
.. literalinclude:: _PasswordHasBeenResetEvent/_MyEventListener.php | ||
:caption: EXT:my_extension/Classes/Backend/EventListener/MyEventListener.php | ||
|
||
.. _PasswordHasBeenResetEvent-api: | ||
|
||
API | ||
=== | ||
|
||
.. include:: /CodeSnippets/Events/Backend/PasswordHasBeenResetEvent.rst.txt |
18 changes: 18 additions & 0 deletions
18
...ntation/ApiOverview/Events/Events/Backend/_PasswordHasBeenResetEvent/_MyEventListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vendor\MyPackage\Backend\EventListener; | ||
|
||
use TYPO3\CMS\Backend\Authentication\Event\PasswordHasBeenResetEvent; | ||
use TYPO3\CMS\Core\Attribute\AsEventListener; | ||
|
||
final class PasswordHasBeenResetEventListener | ||
{ | ||
#[AsEventListener('my-package/backend/password-has-been-reset')] | ||
public function __invoke(PasswordHasBeenResetEvent $event): void | ||
{ | ||
$userUid = $event->userId; | ||
// Do something with the be_user UID | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Documentation/CodeSnippets/Events/Backend/PasswordHasBeenResetEvent.rst.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets | ||
.. php:namespace:: TYPO3\CMS\Backend\Authentication\Event | ||
.. php:class:: PasswordHasBeenResetEvent | ||
.. php:attr:: userId | ||
:readonly: | ||
:public: |