Bruna no longer works alone: Gorm wants to get into the kitchen too, and he has hired Pippin (to wait tables). Declare every staff member in security.yaml, and redeploy at every hire? Unthinkable. The accounts are going to live in the database.
To Symfony, a user is simply an object that implements UserInterface: an identifier and roles. And if it has a password, it also implements PasswordAuthenticatedUserInterface.
Your mission
- Turn the
Employeentity (staff member) into a Symfony user with a password:- you log in with your email;
- every logged-in staff member has at least the
ROLE_USERrole, on top of the stored roles.
- In
security.yaml, replace the in-memory user with a Doctrine provider: staff members areEmployeobjects, looked up by theiremail.
The app:embaucher command (hire the staff, already written) creates three accounts, with passwords hashed by UserPasswordHasherInterface. It fails as long as Employe is not a user: run it again in the console afterwards, it displays the demo accounts.
Reminder
Symfony never stores a password in plain text. hashPassword() uses the algorithm from security.yaml (auto: bcrypt or argon2), and the firewall checks it at login.