Skip to content

Commit

Permalink
Merged in bugfix (pull request FriendsOfSymfony#1)
Browse files Browse the repository at this point in the history
Bugfix

Approved-by: Dani González <[email protected]>
  • Loading branch information
Dani González committed May 2, 2020
2 parents 1e932f6 + 637637a commit b2f321d
Show file tree
Hide file tree
Showing 36 changed files with 186 additions and 211 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.php_cs
.php_cs.cache
.phpunit.result.cache
.idea/
composer.lock
phpunit.xml
vendor/
2 changes: 2 additions & 0 deletions Command/ActivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->userManipulator->activate($username);

$output->writeln(sprintf('User "%s" has been activated.', $username));

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->userManipulator->changePassword($username, $password);

$output->writeln(sprintf('Changed password for user <comment>%s</comment>', $username));

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Command/CreateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->userManipulator->create($username, $password, $email, !$inactive, $superadmin);

$output->writeln(sprintf('Created user <comment>%s</comment>', $username));

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Command/DeactivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->userManipulator->deactivate($username);

$output->writeln(sprintf('User "%s" has been deactivated.', $username));

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Command/RoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

$manipulator = $this->userManipulator;
$this->executeRoleCommand($manipulator, $output, $username, $super, $role);

return 0;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Controller/ChangePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -31,7 +31,7 @@
* @author Thibault Duplessis <[email protected]>
* @author Christophe Coevoet <[email protected]>
*/
class ChangePasswordController extends Controller
class ChangePasswordController extends AbstractController
{
private $eventDispatcher;
private $formFactory;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function changePasswordAction(Request $request)
}

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_INITIALIZE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::CHANGE_PASSWORD_INITIALIZE);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -72,7 +72,7 @@ public function changePasswordAction(Request $request)

if ($form->isSubmitted() && $form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_SUCCESS, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::CHANGE_PASSWORD_SUCCESS);

$this->userManager->updateUser($user);

Expand All @@ -81,7 +81,7 @@ public function changePasswordAction(Request $request)
$response = new RedirectResponse($url);
}

$this->eventDispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$this->eventDispatcher->dispatch(new FilterUserResponseEvent($user, $request, $response), FOSUserEvents::CHANGE_PASSWORD_COMPLETED);

return $response;
}
Expand Down
20 changes: 10 additions & 10 deletions Controller/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\GroupInterface;
use FOS\UserBundle\Model\GroupManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -32,7 +32,7 @@
* @author Thibault Duplessis <[email protected]>
* @author Christophe Coevoet <[email protected]>
*/
class GroupController extends Controller
class GroupController extends AbstractController
{
private $eventDispatcher;
private $formFactory;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function editAction(Request $request, $groupName)
$group = $this->findGroupBy('name', $groupName);

$event = new GetResponseGroupEvent($group, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_EDIT_INITIALIZE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::GROUP_EDIT_INITIALIZE);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -95,7 +95,7 @@ public function editAction(Request $request, $groupName)

if ($form->isSubmitted() && $form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_EDIT_SUCCESS, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::GROUP_EDIT_SUCCESS);

$this->groupManager->updateGroup($group);

Expand All @@ -104,7 +104,7 @@ public function editAction(Request $request, $groupName)
$response = new RedirectResponse($url);
}

$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_EDIT_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
$this->eventDispatcher->dispatch(new FilterGroupResponseEvent($group, $request, $response), FOSUserEvents::GROUP_EDIT_COMPLETED);

return $response;
}
Expand All @@ -126,7 +126,7 @@ public function newAction(Request $request)
{
$group = $this->groupManager->createGroup('');

$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_CREATE_INITIALIZE, new GroupEvent($group, $request));
$this->eventDispatcher->dispatch(new GroupEvent($group, $request), FOSUserEvents::GROUP_CREATE_INITIALIZE);

$form = $this->formFactory->createForm();
$form->setData($group);
Expand All @@ -135,7 +135,7 @@ public function newAction(Request $request)

if ($form->isSubmitted() && $form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_CREATE_SUCCESS, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::GROUP_CREATE_SUCCESS);

$this->groupManager->updateGroup($group);

Expand All @@ -144,7 +144,7 @@ public function newAction(Request $request)
$response = new RedirectResponse($url);
}

$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_CREATE_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
$this->eventDispatcher->dispatch(new FilterGroupResponseEvent($group, $request, $response), FOSUserEvents::GROUP_CREATE_COMPLETED);

return $response;
}
Expand All @@ -169,7 +169,7 @@ public function deleteAction(Request $request, $groupName)

$response = new RedirectResponse($this->generateUrl('fos_user_group_list'));

$this->eventDispatcher->dispatch(FOSUserEvents::GROUP_DELETE_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
$this->eventDispatcher->dispatch(new FilterGroupResponseEvent($group, $request, $response), FOSUserEvents::GROUP_DELETE_COMPLETED);

return $response;
}
Expand Down
12 changes: 6 additions & 6 deletions Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -30,7 +30,7 @@
*
* @author Christophe Coevoet <[email protected]>
*/
class ProfileController extends Controller
class ProfileController extends AbstractController
{
private $eventDispatcher;
private $formFactory;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function editAction(Request $request)
}

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_INITIALIZE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::PROFILE_EDIT_INITIALIZE);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -86,7 +86,7 @@ public function editAction(Request $request)

if ($form->isSubmitted() && $form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_SUCCESS, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::PROFILE_EDIT_SUCCESS);

$this->userManager->updateUser($user);

Expand All @@ -95,7 +95,7 @@ public function editAction(Request $request)
$response = new RedirectResponse($url);
}

$this->eventDispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$this->eventDispatcher->dispatch(new FilterUserResponseEvent($user, $request, $response), FOSUserEvents::PROFILE_EDIT_COMPLETED);

return $response;
}
Expand Down
18 changes: 9 additions & 9 deletions Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -33,7 +33,7 @@
* @author Thibault Duplessis <[email protected]>
* @author Christophe Coevoet <[email protected]>
*/
class RegistrationController extends Controller
class RegistrationController extends AbstractController
{
private $eventDispatcher;
private $formFactory;
Expand All @@ -59,7 +59,7 @@ public function registerAction(Request $request)
$user->setEnabled(true);

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::REGISTRATION_INITIALIZE);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -73,7 +73,7 @@ public function registerAction(Request $request)
if ($form->isSubmitted()) {
if ($form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::REGISTRATION_SUCCESS);

$this->userManager->updateUser($user);

Expand All @@ -82,13 +82,13 @@ public function registerAction(Request $request)
$response = new RedirectResponse($url);
}

$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
$this->eventDispatcher->dispatch(new FilterUserResponseEvent($user, $request, $response), FOSUserEvents::REGISTRATION_COMPLETED);

return $response;
}

$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_FAILURE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::REGISTRATION_FAILURE);

if (null !== $response = $event->getResponse()) {
return $response;
Expand Down Expand Up @@ -145,7 +145,7 @@ public function confirmAction(Request $request, $token)
$user->setEnabled(true);

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_CONFIRM, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::REGISTRATION_CONFIRM);

$userManager->updateUser($user);

Expand All @@ -154,7 +154,7 @@ public function confirmAction(Request $request, $token)
$response = new RedirectResponse($url);
}

$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_CONFIRMED, new FilterUserResponseEvent($user, $request, $response));
$this->eventDispatcher->dispatch(new FilterUserResponseEvent($user, $request, $response), FOSUserEvents::REGISTRATION_CONFIRMED);

return $response;
}
Expand Down
22 changes: 11 additions & 11 deletions Controller/ResettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use FOS\UserBundle\Mailer\MailerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use FOS\UserBundle\Util\TokenGeneratorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -32,7 +32,7 @@
* @author Thibault Duplessis <[email protected]>
* @author Christophe Coevoet <[email protected]>
*/
class ResettingController extends Controller
class ResettingController extends AbstractController
{
private $eventDispatcher;
private $formFactory;
Expand Down Expand Up @@ -85,15 +85,15 @@ public function sendEmailAction(Request $request)
$user = $this->userManager->findUserByUsernameOrEmail($username);

$event = new GetResponseNullableUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_SEND_EMAIL_INITIALIZE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::RESETTING_SEND_EMAIL_INITIALIZE);

if (null !== $event->getResponse()) {
return $event->getResponse();
}

if (null !== $user && !$user->isPasswordRequestNonExpired($this->retryTtl)) {
$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_RESET_REQUEST, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::RESETTING_RESET_REQUEST);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -104,7 +104,7 @@ public function sendEmailAction(Request $request)
}

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_SEND_EMAIL_CONFIRM, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::RESETTING_SEND_EMAIL_CONFIRM);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -115,7 +115,7 @@ public function sendEmailAction(Request $request)
$this->userManager->updateUser($user);

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_SEND_EMAIL_COMPLETED, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::RESETTING_SEND_EMAIL_COMPLETED);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand Down Expand Up @@ -163,7 +163,7 @@ public function resetAction(Request $request, $token)
}

$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_RESET_INITIALIZE, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::RESETTING_RESET_INITIALIZE);

if (null !== $event->getResponse()) {
return $event->getResponse();
Expand All @@ -176,7 +176,7 @@ public function resetAction(Request $request, $token)

if ($form->isSubmitted() && $form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::RESETTING_RESET_SUCCESS, $event);
$this->eventDispatcher->dispatch($event, FOSUserEvents::RESETTING_RESET_SUCCESS);

$this->userManager->updateUser($user);

Expand All @@ -186,8 +186,8 @@ public function resetAction(Request $request, $token)
}

$this->eventDispatcher->dispatch(
FOSUserEvents::RESETTING_RESET_COMPLETED,
new FilterUserResponseEvent($user, $request, $response)
new FilterUserResponseEvent($user, $request, $response),
FOSUserEvents::RESETTING_RESET_COMPLETED
);

return $response;
Expand Down
Loading

0 comments on commit b2f321d

Please sign in to comment.