1

symfony2 アーキテクチャーと便利な FosUserBundle を使用してユーザーを処理する新しいプロジェクトを開始しています。

私のアプリケーションには、ユーザーとエンタープライズの 2 種類のユーザーがいます。

ユーザーフォームを作成しました(フォームが埋め込まれています)。今、EntrepriseForm (別の埋め込みフォーム) を作成したいのですが、FosUserConfiguration で 1 つの登録フォーム タイプしか許可されていないため、行き詰まっています。

それが役立つ場合は、config.yml がどのように見えるかを次に示します。

fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Digin\UserBundle\Entity\User
registration:
    confirmation:
        from_email: # Use this node only if you don't want the global email address for the confirmation email
            address:        xxx@xxx.org
            sender_name:    xxx
        enabled:    true # change to true for required email confirmation
        template:   FOSUserBundle:Registration:email.txt.twig
    form:
        type:               mybundle_user_registration
        handler:            fos_user.registration.form.handler.default
        name:               fos_user_registration_form
        validation_groups:  [Registration]

私はそれをどのように行うべきかについて何か考えはありますか?

4

1 に答える 1

1

あなたの場所に新しい役割を追加します( symfony は他の役割を無視しsecurity.ymlて開始することを忘れないでください)。ROLE_次に、ListenerInteractiveLoginListenerを追加して、異なるロールでログインした後に追加のリダイレクトを行います。そして、JMSSecurityExtraBundleを追加します。これは、アノテーションだけでアクションとコントローラーのアクセスを検証するのに役立ちます。

use JMS\SecurityExtraBundle\Annotation\PreAuthorize;

class MyService
{
    /** @PreAuthorize("hasRole('A') or (hasRole('B') and hasRole('C'))") */
    public function secureMethod()
    {
        // ...
    }
}

ドキュメントを見てください: http://jmsyst.com/bundles/JMSSecurityExtraBundle/master/installation

于 2012-11-23T08:36:53.417 に答える