File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313
1414use Derhansen \FeChangePwd \Domain \Model \Dto \ChangePassword ;
1515use Derhansen \FeChangePwd \Event \AfterPasswordUpdatedEvent ;
16+ use Derhansen \FeChangePwd \Event \ModifyUpdatePasswordResponseEvent ;
1617use Derhansen \FeChangePwd \Exception \InvalidEmailAddressException ;
1718use Derhansen \FeChangePwd \Service \FrontendUserService ;
1819use Derhansen \FeChangePwd \Service \SettingsService ;
@@ -79,10 +80,16 @@ public function updateAction(ChangePassword $changePassword): ResponseInterface
7980 LocalizationUtility::translate ('passwordUpdated ' , 'FeChangePwd ' ),
8081 LocalizationUtility::translate ('passwordUpdated.title ' , 'FeChangePwd ' )
8182 );
82- return $ this ->redirect ('edit ' );
83+ $ response = $ this ->redirect ('edit ' );
84+ } else {
85+ $ response = $ this ->htmlResponse ();
8386 }
8487
85- return $ this ->htmlResponse ();
88+ $ modifyUpdatePasswordResponseEvent = $ this ->eventDispatcher ->dispatch (
89+ new ModifyUpdatePasswordResponseEvent ($ this ->request , $ this ->settings , $ response )
90+ );
91+
92+ return $ modifyUpdatePasswordResponseEvent ->getResponse ();
8693 }
8794
8895 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Derhansen \FeChangePwd \Event ;
6+
7+ use Psr \Http \Message \ResponseInterface ;
8+ use Psr \Http \Message \ServerRequestInterface ;
9+
10+ /**
11+ * This event is triggered before the response for the updateAction is returned. Listeners can use this event
12+ * to modify the response object (e.g. replace it with a custom response)
13+ */
14+ final class ModifyUpdatePasswordResponseEvent
15+ {
16+ public function __construct (
17+ private readonly ServerRequestInterface $ request ,
18+ private readonly array $ settings ,
19+ private ResponseInterface $ response
20+ ) {}
21+
22+ public function getRequest (): ServerRequestInterface
23+ {
24+ return $ this ->request ;
25+ }
26+
27+ public function getSettings (): array
28+ {
29+ return $ this ->settings ;
30+ }
31+
32+ public function getResponse (): ResponseInterface
33+ {
34+ return $ this ->response ;
35+ }
36+
37+ public function setResponse (ResponseInterface $ response ): void
38+ {
39+ $ this ->response = $ response ;
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ The extension currently contains the following PSR-14 events:
145145
146146* Derhansen\FeChangePwd\Controller\PasswordController
147147 * ` AfterPasswordUpdatedEvent `
148+ * ` ModifyUpdatePasswordResponseEvent `
148149* Derhansen\FeChangePwd\Middleware\ForcePasswordChangeRedirect
149150 * ` ModifyRedirectUrlParameterEvent `
150151
Original file line number Diff line number Diff line change 88 'author ' => 'Torben Hansen ' ,
99 'author_email ' => 'torben@derhansen.com ' ,
1010 'state ' => 'stable ' ,
11- 'version ' => '5.2 .0 ' ,
11+ 'version ' => '5.3 .0 ' ,
1212 'constraints ' => [
1313 'depends ' => [
1414 'typo3 ' => '13.4.0-13.4.99 '
You can’t perform that action at this time.
0 commit comments