I have a special use case I can not solve. When the user click on Facebook Connect and find an similar email in my DB. I want to ask the user if the account belongs to him.

If the answer is yes, he needs to connect with his account and then add the Facebook ID in the DB.

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

I don't find the best way to do this. Can someone help me ?

有帮助吗?

解决方案

In controller you can check whether email exists in DB or not using fos user bundle user manager

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

After user confirms, you can use implemented facebook provider to do necessary action.

between, I have a question for you,

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top