Skip to content

Commit

Permalink
Merge pull request #131 from samuele-mrapps/patch-1
Browse files Browse the repository at this point in the history
fix issue #91 and reduce flush
  • Loading branch information
krispypen committed Jan 27, 2015
2 parents 1439220 + a265fe0 commit 4b02802
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Kunstmaan/UserManagementBundle/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,9 @@ public function addAction(Request $request)
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isValid()) {
$em->persist($user);
$em->flush();

/* @var UserManipulator $manipulator */
$manipulator = $this->get('fos_user.util.user_manipulator');
$manipulator->changePassword($user->getUsername(), $user->getPlainpassword());
/* @var UserManager $userManager */
$userManager = $this->container->get('fos_user.user_manager');
$userManager->updateUser($user, true);

$this->get('session')->getFlashBag()->add(
'success',
Expand Down Expand Up @@ -167,13 +164,10 @@ public function editAction(Request $request, $id)
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isValid()) {
if ($user->getPlainpassword() != "") {
$manipulator = $this->get('fos_user.util.user_manipulator');
$manipulator->changePassword($user->getUsername(), $user->getPlainpassword());
}
$user->setPlainpassword("");
$em->persist($user);
$em->flush();
/* @var UserManager $userManager */
$userManager = $this->container->get('fos_user.user_manager');
$userManager->updateUser($user, true);

$this->get('session')->getFlashBag()->add(
'success',
'User \'' . $user->getUsername() . '\' has been edited!'
Expand Down

0 comments on commit 4b02802

Please sign in to comment.