|
@@ -54,20 +54,14 @@ class SecurityController extends Controller
|
|
|
/**
|
|
|
* @Route("/admin/edituser/{id}", name="admin_edituser")
|
|
|
*/
|
|
|
- public function editUserAction(Request $request, UserPasswordEncoderInterface $encoder, $id)
|
|
|
+ public function editUserAction(Request $request, UserPasswordEncoderInterface $encoder, User $user)
|
|
|
{
|
|
|
- $em = $this->getDoctrine()->getManager();
|
|
|
- $repo = $em->getRepository('AppBundle:User');
|
|
|
- $user = $repo->find($id);
|
|
|
-
|
|
|
$form = $this->createForm(UserEditType::class, $user);
|
|
|
-
|
|
|
$form->handleRequest($request);
|
|
|
if ($form->isSubmitted() && $form->isValid())
|
|
|
{
|
|
|
+ $em = $this->getDoctrine()->getManager();
|
|
|
$user = $form->getData();
|
|
|
- //$encoded = $encoder->encodePassword($user, $user->getPassword());
|
|
|
- //$user->setPassword($encoded);
|
|
|
$em->flush();
|
|
|
$this->addFlash('success', 'L\'utilisateur a été modifié');
|
|
|
return $this->redirectToRoute('admin_index');
|
|
@@ -94,16 +88,15 @@ class SecurityController extends Controller
|
|
|
/**
|
|
|
* @Route("/admin/deluser/{id}", name="admin_deluser")
|
|
|
*/
|
|
|
- public function delUserAction (Request $request, $id)
|
|
|
+ public function delUserAction (Request $request, User $user)
|
|
|
{
|
|
|
- $em = $this->getDoctrine()->getManager();
|
|
|
- $repo = $em->getRepository('AppBundle:User');
|
|
|
- $user = $repo->find($id);
|
|
|
$form = $this->get('form.factory')->create();
|
|
|
+ $form->handleRequest($request);
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
+ $em = $this->getDoctrine()->getManager();
|
|
|
$em->remove($user);
|
|
|
$em->flush();
|
|
|
- $this->addFlash("L'utilisateur a bien été supprimé");
|
|
|
+ $this->addFlash("success", "L'utilisateur a bien été supprimé");
|
|
|
return $this->redirectToRoute('admin_index');
|
|
|
}
|
|
|
return $this->render('@App/security/supprimeruser.html.twig', array (
|