当我以 role_user 身份登录我的网站时,当我尝试编辑我的个人资料时,我尝试将我的登录名更改为我的数据库中的某个登录名,我看到错误 - “此登录名已被使用”,好的,但是当我刷新我的页面我看到我授权为新登录,它不好
我有这个表单生成器:
namespace User\WalletBundle\Form;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class EditForm extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('username', null, array('attr' => array('placeholder' => 'Login')));
$builder->add('email', 'email', array('attr' => array('placeholder' => 'E-mail')));
$builder->add('mobile', 'number', array('attr' => array('placeholder' => 'Mobile','maxlength' => 10)));
$builder->add('password', 'repeated', array(
'type' => 'password',
'invalid_message' => 'Пароли не совпадают',
'options' => array('label'=>'','required' => false, 'always_empty' => false)));
$builder->add('old_pass','password',array('attr' => array('placeholder' => 'Old pass')));
}
public function getName() {
return 'edit_form';
}
public function getDefaultOptions(array $options) {
return array(
'data_class' => 'User\WalletBundle\Entity\User',
);
}
}
我想我不知道这个系统是如何工作的(安全性),也许我可以阅读我的问题,请链接。很感谢
非常非常抱歉我的英语
在我的控制器中,为了测试,我编写了这段代码
/**
* @Secure(roles="ROLE_USER")
* @Template("UserWalletBundle:Wallet:settings.html.twig")
*/
public function settingsAction(Request $request) {
$user_edit = $this->getDoctrine()->getRepository('UserWalletBundle:User')->findOneById($this->get('security.context')->getToken()->getUser()->getId());
$form = $this->createForm(new EditForm(), $user_edit);
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
// Now i have login Alice, and i want change my profile, set login Test, but Test is created some user in DB, ofcours i see error This login is already used
if ($form->isValid()) {
//Do anything
} else {
// There i see error This login is already used
return array('form' => $form->createView());
}
} else
return array('form' => $form->createView());
}
现在我刷新我的页面,我看到我授权为用户名(登录)“测试”,为什么以及如何解决这个问题?