質問

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