Skip to content

Commit

Permalink
[FEATURE] Dispatch event after BE user's password reset (#5108)
Browse files Browse the repository at this point in the history
* [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
linawolf and froemken authored Dec 10, 2024
1 parent cf1ac04 commit 47d6d00
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
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
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,10 @@
'targetFileName' => 'CodeSnippets/Events/Backend/AfterRawPageRowPreparedEvent.rst.txt',
'withCode' => false,
],
[
'action' => 'createPhpClassDocs',
'class' => \TYPO3\CMS\Backend\Authentication\Event\PasswordHasBeenResetEvent::class,
'targetFileName' => 'CodeSnippets/Events/Backend/PasswordHasBeenResetEvent.rst.txt',
'withCode' => false,
],
];
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:

0 comments on commit 47d6d00

Please sign in to comment.