FOSFacebookBundle + FosUserBundle Email exists in BDD

I have a special use case that I cannot solve. When a user clicks on Facebook Connect

and finds a similar email in my DB. I want to ask the user if they own an account.

If the answer is yes, he needs to connect to his account and then add it Facebook ID

to the database.

If the answer is no, I create a new user in the database and login.

I can't find a better way to do this. Can anyone help me?

+3


source to share


1 answer


In the controller, you can check if the mailbox exists in the DB or not using the fos custom package manager

$user = $this->get('fos_user.user_manager')->findUserByEmail($email);

      

After user confirmation, you can use the implemented facebook provider to perform the required actions.



in between, I have a question for you,

"If the answer is no, I create a new user in the database and log in."

how do you create a new user with the same email address (assuming the email is unique)?

+2


source







All Articles