我用它来编码我的密码:
$entity->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha1');
$password = $encoder->encodePassword($editForm->get('password')->getData(), $entity->getSalt());
$entity->setPassword($password);
但 relizar 怎么会反其道而行之呢?也就是说,我怎样才能得到未加密的密码?如果我用这个
$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'));
当我去编辑crud中的用户时,我有这个:在更新操作中:
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(),
);
}
问题是我无法获得编码密码为空白。(在分贝是正确的)谢谢