I have integrated FOS bundle in my project. Now, I want to allow multiple users with the same email, but FOS won't allow it.
How could I change the user implementation to allow that?
I have integrated FOS bundle in my project. Now, I want to allow multiple users with the same email, but FOS won't allow it.
How could I change the user implementation to allow that?
I had the same problem in my project. I solved it overriding some Doctrine definition on my User entity, that extends FOS' BaseUser.
I've done like this:
/**
* @ORM\Entity()
* @ORM\Table(name="user", uniqueConstraints={
* @ORM\UniqueConstraint(name="user_U_1", columns={"username"})
* })
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="emailCanonical",
* column=@ORM\Column(
* name="email_canonical",
* type="string",
* length=255,
* nullable=true,
* unique=false
* )
* ),
* @ORM\AttributeOverride(name="usernameCanonical",
* column=@ORM\Column(
* name="username_canonical",
* type="string",
* length=255,
* nullable=true,
* unique=false
* )
* )
* })
*/
class User extends BaseUser
{
[...]
}
The trick is done redefining the email_canonical field setting unique=false