Skip to content

Commit dc40369

Browse files
committed
Dispatches FOSUserEvents::RESETTING_SEND_EMAIL_FAILURE event whenever
resetting email is not send due to non-existing username or expired password request.
1 parent 1049935 commit dc40369

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Controller/ResettingController.php

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public function sendEmailAction(Request $request)
117117
$event = new GetResponseUserEvent($user, $request);
118118
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_SEND_EMAIL_COMPLETED, $event);
119119

120+
if (null !== $event->getResponse()) {
121+
return $event->getResponse();
122+
}
123+
} else {
124+
$event = new GetResponseNullableUserEvent($user, $request);
125+
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_SEND_EMAIL_FAILURE, $event);
126+
120127
if (null !== $event->getResponse()) {
121128
return $event->getResponse();
122129
}

FOSUserEvents.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,24 @@ final class FOSUserEvents
258258
/**
259259
* The RESETTING_SEND_EMAIL_COMPLETED event occurs after the email is sent.
260260
*
261-
* This event allows you to set the response to bypass the the redirection after the email is sent.
261+
* This event allows you to set the response to bypass the redirection after the email is sent.
262262
* The event listener method receives a FOS\UserBundle\Event\GetResponseUserEvent instance.
263263
*
264264
* @Event("FOS\UserBundle\Event\GetResponseUserEvent")
265265
*/
266266
const RESETTING_SEND_EMAIL_COMPLETED = 'fos_user.resetting.send_email.completed';
267267

268+
/**
269+
* The RESETTING_SEND_EMAIL_FAILURE event occurs whenever email is not send due to non-existing username
270+
* or expired password request.
271+
*
272+
* This event allows you to set the response to bypass the redirection after the email is not sent.
273+
* The event listener method receives a FOS\UserBundle\Event\GetResponseNullableUserEvent instance.
274+
*
275+
* @Event("FOS\UserBundle\Event\GetResponseNullableUserEvent")
276+
*/
277+
const RESETTING_SEND_EMAIL_FAILURE = 'fos_user.resetting.send_email.failure';
278+
268279
/**
269280
* The USER_CREATED event occurs when the user is created with UserManipulator.
270281
*

0 commit comments

Comments
 (0)