fos ユーザーバンドルで symfony 2.0 を使用していますが、プロファイルの変更に関しては、非常に奇妙な動作が発生します。
私のユーザー エンティティでは、次のように FOSValidator を使用しています。
@FOSValidator\Unique(property="usernameCanonical", message="fos_user.username.already_used", groups={"Facebook", "profile_username"})
私の ProfileController の
フォームは次の方法で検証されます
$form = $this->container->get('form.factory')->create(new ProfileSimpleFormType(array($field)), $user);
$session = $this->container->get("session");
if ($this->container->get('request')->getMethod() == 'POST') {
$form->bindRequest($this->container->get('request'));
if ($form->isValid()) {
$this->container->get('fos_user.user_manager')->updateUser($user);
return $this->container->get('templating')->renderResponse('FOSUserBundle:Profile:show_field.html.' . $this->container->getParameter('fos_user.template.engine'), array(
'field' => $field,
'user' => $user
));
// }
}else{
$user2 = $this->container->get('security.context')->getToken()->getUser();
}
}
しかし今、奇妙な振る舞いに:
ユーザー名が存在するためにフォームが有効でない場合、 $user2 は既存のユーザー名でユーザーに設定されるため、ユーザー名を変更するだけで他のアカウントを乗っ取ることができます。
ビューの種類のリスナーをデバッグしようとしましたが、既存のユーザー名がセキュリティ トークンに設定されているポイントが見つかりません。