Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP9+Symfony] nie zahashowane hasło
dopelganger
post
Post #1





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


cześć

kiedy edytuje w cmsie (CRUD) użytkownika: hasło zapisuje do bazy nie zahashowane :/

a w pliku security.yml mam:

  1. security:
  2. encoders:
  3. FOS\UserBundle\Model\UserInterface: sha512


na stronie -edycja profilu- zapisuje prawidłowo.

Prosze o pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Forti
post
Post #2





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


Pokaż kod akcji w controller (IMG:style_emoticons/default/smile.gif) Musisz hasło kodować używając odpowiedniego komponentu w symfony. Samo nigdy nic się nie dzieje.
Go to the top of the page
+Quote Post
dopelganger
post
Post #3





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


Cytat(Forti @ 29.12.2015, 10:30:33 ) *
Pokaż kod akcji w controller (IMG:style_emoticons/default/smile.gif) Musisz hasło kodować używając odpowiedniego komponentu w symfony. Samo nigdy nic się nie dzieje.


  1. /**
  2.   * Displays a form to edit an existing User entity.
  3.   *
  4.   * @Route("/{id}/edit", name="backend_cms_users_edit")
  5.   * @Method("GET")
  6.   * @Template()
  7.   */
  8. public function editAction($id)
  9. {
  10. $em = $this->getDoctrine()->getManager();
  11.  
  12. $entity = $em->getRepository('UserBundle:User')->find($id);
  13.  
  14. if (!$entity) {
  15. throw $this->createNotFoundException('Unable to find User entity.');
  16. }
  17.  
  18. $editForm = $this->createEditForm($entity);
  19. $deleteForm = $this->createDeleteForm($id);
  20.  
  21. return array(
  22. 'entity' => $entity,
  23. 'edit_form' => $editForm->createView(),
  24. 'delete_form' => $deleteForm->createView(),
  25. );
  26. }
  27.  
  28. /**
  29.   * Creates a form to edit a User entity.
  30.   *
  31.   * @param User $entity The entity
  32.   *
  33.   * @return \Symfony\Component\Form\Form The form
  34.   */
  35. private function createEditForm(User $entity)
  36. {
  37. $form = $this->createForm(new UserType(), $entity, array(
  38. 'action' => $this->generateUrl('backend_cms_users_update', array('id' => $entity->getId())),
  39. 'method' => 'PUT',
  40. ));
  41.  
  42. $form->add('submit', 'submit', array('label' => 'ZAPISZ'));
  43.  
  44. return $form;
  45. }
  46. /**
  47.   * Edits an existing User entity.
  48.   *
  49.   * @Route("/{id}", name="backend_cms_users_update")
  50.   * @Method("PUT")
  51.   * @Template("UserBundle:User:edit.html.twig")
  52.   */
  53. public function updateAction(Request $request, $id)
  54. {
  55. $em = $this->getDoctrine()->getManager();
  56.  
  57. $entity = $em->getRepository('UserBundle:User')->find($id);
  58.  
  59. if (!$entity) {
  60. throw $this->createNotFoundException('Unable to find User entity.');
  61. }
  62.  
  63. $deleteForm = $this->createDeleteForm($id);
  64. $editForm = $this->createEditForm($entity);
  65. $editForm->handleRequest($request);
  66.  
  67. if ($editForm->isValid()) {
  68. $em->flush();
  69.  
  70. return $this->redirect($this->generateUrl('backend_cms_users_edit', array('id' => $id)));
  71. }
  72.  
  73. return array(
  74. 'entity' => $entity,
  75. 'edit_form' => $editForm->createView(),
  76. 'delete_form' => $deleteForm->createView(),
  77. );
  78. }
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 12.10.2025 - 07:53