Why is it not possible to "Create a User if Doesn't Exist"?

I’m using the Facebook login module and trying to use ‘Make changes to a thing’ to update the user’s details after login, or create the User with those details if the record doesn’t yet exist. I can select “create if the thing doesn’t exist”…

But as soon as I specify :first item, which I need to do in order for the search to return one result, the option to “Create if doesn’t exist” disappears.

Should the Facebook login create the User record automatically? If not, I’m not sure how to address this…

Not 100% sure if I understand the question, but here’s my stab at it:

With Facebook login, a new user is automatically created if it is the current user’s first time logging in with your app. If you need to change fields attached to that user, you would just use the command “Make changes to Current User”

We support creating things if they don’t exist in this action (which you should use with caution by the way, it’s rare that you try to modify something that doesn’t exist, and can lead to weird situations), but for users it’s a bit more complicated as we need to generate a password, etc. Use the ‘Create an account for someone else’ action for this.

1 Like

The problem with creating an account for someone else when Facebook is the primary login mechanism is - if User A invites User B to the app using a different email address than User B’s Facebook email address, how do you link User B to the invite?

In my case I have a few objects that I’m associating with User B on the Invite event and I want to be able to tie it all together when User B signs up to the app.

Also, a much more basic concern - how do you prevent the creation of duplicate User records when a user signs in with Facebook if you just Add a user when the user is logged in. Does the account / login system take care of duplicate user accounts automatically?

We check emails as a unique identifier, so for facebook that’s what we look it. if a user signed up with email and then logs in with Facebook, we merge accounts.

Also, you can’t create an account for someone with facebook, but you can create an account with their email. if they use facebook later with the same email, what i describe above will happen.

Ok that’s good to know, thanks for the explanation.

Do you automatically create a user record on Facebook login or is that something the app needs to do manually? If it’s supposed to be automatic I think there might be a bug with this.

It’s automatic. If you think there is a bug please fill a bug report and we’ll look into it. What is the bug though, in a nutshell?

Via email or on the forum?

Facebook login adds a user on one account but not on another. It’s the same app so I can’t see any reason for the inconsistency. It seems to be logging both users in though because I’m displaying the Facebook profile pic on the page.

Just tested it on the Live version of the app and it’s working ok there. Is there any difference between Debug and Live in terms of the way Facebook login behaves?

well the biggest difference is the URLs you’ve set up with facebook and the keys you’ve entered in BUbble. Otherwise no, it’s the same code.

Ok, I’ve logged a bug…

Hey @emmanuel,

I read this but the “merge” function i think is not working as expected.

My workflow is:

  1. Signup by email
  2. Logout
  3. Try to Login with Facebook
  4. Get the error “This email is already in use”

A. Is there any way, if this email is already in use, to automatically login and associate that Facebook to that account?
B. Can I add a button in the page “edit profile” where the user by clicking on it can associate a Facebook account?
C. Can I do the reverse action if somebody what to remove the association?


PS. I’ve opened a bug too with this: [Solved] Retrieve data from Facebook for an already existing user