Reputation: 13
I'm starting a new project, using a symfony2 architercture and the usefull FosUserBundle to handle my users.
In my application, i have 2 different types of users, which are : User and Entreprise.
I created a Userform (with embedded form in it). Now i want to create a EntrepriseForm (with a different embedded form) but i'm stuck, due to FosUserConfiguration allowing only 1 registration form type.
If it can helps, here is how my config.yml looks like :
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: [email protected]
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]
Any idea about how i should do that ?
Upvotes: 1
Views: 665
Reputation: 1702
On your place I will add a new Role in your security.yml
(remember to start it with ROLE_
symfony ignores other roles). Then add the Listener InteractiveLoginListener
to do some extra stuff redirections after login on diffrent roles. And then add JMSSecurityExtraBundle That will help you to validate the access in accions and controllers just by annotations:
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
class MyService
{
/** @PreAuthorize("hasRole('A') or (hasRole('B') and hasRole('C'))") */
public function secureMethod()
{
// ...
}
}
Look at the documentation: http://jmsyst.com/bundles/JMSSecurityExtraBundle/master/installation
Upvotes: 1