Dispatch user events after password reset

Previously PasswordChanged was never sent
This commit is contained in:
Clark Winkelmann 2018-01-09 03:44:06 +01:00
parent 26e53fc51b
commit f3e29ab801

View File

@ -11,11 +11,13 @@
namespace Flarum\Forum\Controller;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Http\Controller\ControllerInterface;
use Flarum\Http\SessionAuthenticator;
use Flarum\Http\UrlGenerator;
use Flarum\User\PasswordToken;
use Flarum\User\UserValidator;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Validation\ValidationException;
use Psr\Http\Message\ServerRequestInterface as Request;
@ -23,6 +25,8 @@ use Zend\Diactoros\Response\RedirectResponse;
class SavePasswordController implements ControllerInterface
{
use DispatchEventsTrait;
/**
* @var UrlGenerator
*/
@ -49,12 +53,13 @@ class SavePasswordController implements ControllerInterface
* @param UserValidator $validator
* @param Factory $validatorFactory
*/
public function __construct(UrlGenerator $url, SessionAuthenticator $authenticator, UserValidator $validator, Factory $validatorFactory)
public function __construct(UrlGenerator $url, SessionAuthenticator $authenticator, UserValidator $validator, Factory $validatorFactory, Dispatcher $events)
{
$this->url = $url;
$this->authenticator = $authenticator;
$this->validator = $validator;
$this->validatorFactory = $validatorFactory;
$this->events = $events;
}
/**
@ -88,6 +93,8 @@ class SavePasswordController implements ControllerInterface
$token->user->changePassword($password);
$token->user->save();
$this->dispatchEventsFor($token->user);
$token->delete();
$session = $request->getAttribute('session');