パスワードをエンコードするために使用します。
$entity->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha1');
$password = $encoder->encodePassword($editForm->get('password')->getData(), $entity->getSalt());
$entity->setPassword($password);
しかし、どのようにリザールは反対に踏み出すことができますか?つまり、暗号化されていないパスワードを取得するにはどうすればよいですか?これを使うと
$entity->getPassword()
私にこれを示しています:
xOGjEeMdi4nwanOustbbJlDkug8=
お返事ありがとうございます。ユーザーが古いパスワードを入力し、それが正しいことを確認するフォームを作成しようとしています。私がこれを持っている形で:
->add('antigua', 'password', array('property_path' => false))
->add('password', 'repeated', array('first_name' => 'Nueva contraseña','second_name' => 'Repite contraseña','type' => 'password'));
そして、私がクラッド内のユーザーを編集するために行くとき、私はこれを持っています:更新アクションで:
public function updateAction($id)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('miomioBundle:Empleado')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Empleado entity.');
}
$editForm = $this->createForm(new EmpleadoType(), $entity);
$deleteForm = $this->createDeleteForm($id);
$request = $this->getRequest();
**$entity->getPassword() is blank why?**
$editForm->bindRequest($request);
if ($editForm->isValid()){
$em->persist($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('empleado_edit', array('id' => $id)));
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
問題は、エンコードされたパスワードが空白になることができないことです。(dbで正しい)ありがとう