I'm doing an symfony application. I try to implement a user system.
3 type of person can log in: student, teacher and secretary
If I modelise so, how can I done a login class?
In my Student entity I have:
/**
* @var \essaiBundle\Entity\User
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="essaiBundle\Entity\User")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id", referencedColumnName="id")
* })
*/
private $id;
That reference to the user id.
How can I get the role for the user log in?
My security file:
security:
providers:
our_db_provider:
entity: { class: essaiBundle\Entity\User, property: username}
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
firewalls:
login_firewall:
pattern: ^/login$
anonymous: ~
default:
anonymous: ~
http_basic: ~
form_login:
login_path: /login
check_path: /login_check
csrf_provider: security.csrf.token_manager
default_target_path: admin
provider: our_db_provider
encoders:
essaiBundle\Entity\User:
algorithm: bcrypt
cost: 12
Thanks

Student,TeacherandSecretaryentities? Is role mechanism not enough in this case? Also look at Doctrine inheritance, if you have to separate your entities.