Piddien
Piddien

Reputation: 1446

Symfony2 with FOSUserBundle - how to add roles without hierarchy to my application

I am creating a web application where I need 2 roles. Medic and Patient. They are connected through a many-to many relation (patients can have several medics and vice versa), and the medic is supposed to be able to see its patient's data, but not edit it.

I am using FOSUserBundle and have followed the documentation on using roles. However, the documentation as I see it does not help me in creating these roles. I tried the security part of symfony2 documentation, but it shows how to create a role hierarchy - not helping in my case.

How do I proceed in solving this issue?

EDIT: To be more precise: The real question is how to add the two roles. Maybe I don't need the groups...

Upvotes: 0

Views: 6726

Answers (1)

Piddien
Piddien

Reputation: 1446

I think I solved it:

http://symfony.com/doc/current/book/security.html#roles

This role doesn't need to be defined anywhere - you can just start using it.

EDIT: simply do $user->addRole("ROLE_MEDIC");

Upvotes: 2

Related Questions