-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Every facebook login creates a new user #934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is totally normal that authData is stored as _auth_data_facebook in mongodb. Can you make sure, there is never a POST /users with "authData": { Does this problem occurs after setting a property on the user? |
Ok, but I'm saying that there's no column _auth_data_facebook. I've searched the entire log for this "facebook": null, and it only occurs on GET calls from username/password logins. So to facebook login POST calls this never happen. The problem occurs weather I set a property or not, I've tested both cases. I assume it's a problem during the ParseFacebookUtils.logInWithReadPermissionsInBackground call in which the user authdata format is being handled different from how is done on Parse API. |
when you run with VERBOSE=1 and do ParseFacebookUtils.logInWithReadPermissionsInBackground, what is the request that you have. (GET or POST) Then you say:
This is really important, that means that the Facebook auth gets unlinked when you call login. Could you provide the logs when running VERBOSE=1 as well for this case? |
Ok, I'm gonna show you 2 cases: 1) user login with facebook for the first time; 2) reinstall app, and the same user try to login again with facebook 1) Login is successful, but missing the authData on mongodb. Here's the Verbose sequence:
2) Login is successful, but a new user is created on mongodb. Here's the Verbose sequence:
|
Something weird is happening for sure with Facebook signup/login. I'm getting similar issues trying to login/auth via ios. I have parse-server running on heroku, using the most up-to-date versions of both the parse-ios cocoapod and parse-server. From what I can tell when I auth w/Facebook I can see that I've found that (a) removing any beforeSave calls in cloud code stops the issue of duplicate users being created when trying to auth with the same Facebook account however, (b) once a user logs in with Facebook they cannot do anything with their associated objects (i.e., edit their user name, edit owned objects, etc); parse returns the error: 'cannot modify user xxxxxxx'. For more details you can see my ticket: #880 |
Hi @DrBeak1, yep I'm having the same issue on iOS too. |
Still an issue with parse-server 2.1.5 |
@DrBeak1 your problem is on iOS right? What method do you use for login? |
@weengo I'm not sure about Android. in case 1) is Parse.User.currentUser() set correctly? Can you access it's objectId? does the objectId match with what you see in the logs? does the session token match with what you see in the logs? That may be easier to debug for you if you were running locally from the repository directly. |
Hey @flovilmart - Using ParseFacebookUtilsV4 (1.11.1): This method succeeds, returning a user with the correct objectId, a new session token, and an access token for facebook (may be old, it matches the old one stored on my user obj in mongodb. but the one on mongodb is not being updated because my users |
I think this is related to my other issue #755 |
I pass authData: {"twitter": null} to unlink a twitter account according to this doc. For users that have unlinked and linked again database contains Accounts that have not been previously unlinked have only This does not cause any issue for me and everything is still working correctly. I think the authData dict should be removed after an unlink request has been passed so that when user links again the parse dashboard will correctly populate the authData field. |
I just opened #952 that include a 'small' refactoring of the OAuth procedure, as I uncovered a series of weird things there. For the ones running on a local server, please checkout that branch, and run against it. We definitely could remove the authData dict when you unlink, we could also delete the key |
@flovilmart, regarding your questions
One thing I noticed: _Installation is only created on mongodb after the user signup, is that the normal? Sure I can test locally, is there a tutorial on how to set up locally? |
Let's focus on authentication, not throwing more things in there.
And then follow those instructions Don't forget to pass --databaseURI and all relevant options. If you wish you can create a JSON configuration and use it like that: npm start -- path/to/config.json |
Once you've setup your config, I encourage you to test with that branch in the parse-server folder that you clone:
and restart the server |
@flovilmart Ok, everything is setup:
On android I have changed the endpoint to .server("http://localhost:1337/parse/").build() is that right? I have reinstalled the app, but can't login. What am I doing wrong? |
you may have to use ngrok to tunnel the android SDK request to you localhost. |
how did you configure android? can you map the naked xxxx.ngrok.io -> localhost:1337 instead of /parse? |
Android endpoint is like this .server("http://27eace14.ngrok.io/").build() |
Try With /parse at The end in the android, then maybe start parse-server your server with VERBOSE=1 |
how do you set VERBOSE=1 on local server? |
Couldn't set the verbose, but I got this from ngrok inspection POST /parse/users
404 Not Found Response
|
I'm saw some strange thing in Facebook login with Android, using anonymous user, this is the login put:
The objectId is sent because the user exists (anonymous). Then it's try to do a PUT in /parse/classes/_User/5DeGfe43PC. This break all the logic because try to update a existent user, I tried to fix the code, but always show more issues because session or auth (the session check is before the logic with the login, needs a big refactor there). Looking in the code I found that there is no place to update a logged third party user, is always create. I did a test and a fix to this, but the issue with the session is a trouble. I don't know how is the response of parse to fix this (because this problem do not happens with client using parser official server). Here the test of the issue: 0f3116e |
@weengo you haven't put the options --facebookAppIds when you launch the server @Scoup the you do a put to the user you want to add the Facebook authData to the user you're modifying. If you enable anonymous users, you will ever be in that situation. The session check logic makes sense, we don't want anyone to modify you anonymous user. The logic to update a 3rd party logged in user is in RestWrite.js. I'll try to reproduce the issue |
@flovilmart, I understand the session check, but I don't know all the flow when this happens. Because the client is trying to update a anonymous user, the server know that he already have another user, so after this "change" happens the client need to know. I think the server need to send back to client the new objectId and the new Session (because the old one is linked to the anonymous user). Here is another problem: https://github.com/ParsePlatform/parse-server/blob/master/src/RestWrite.js#L223, because, if you see the data of my last post, the client send the facebook provider but sends the anonymous provider (objectId). I'm not sure if this should be fixed in client or the server needs to be aware about that. Then, even if we change the code to let the flow until handleOAuthAuthData, still have the problem of not find the user before save. https://github.com/ParsePlatform/parse-server/blob/master/src/RestWrite.js#L346. And here there is no new session to send to user (since the last one is for the anonymous). So, I'm not sure about all this flow (I started to work in this code yesterday and my lack of understanding of flow could let me do mistakes). But I'm still trying to work on. |
@Scoup I've commented on the commit you provided as I'm not sure what you're trying to achieve. Going back to your issue:
This doesn't break the logic, it makes total sense. What's happening when you're doing a PUT is modify the current user with new information, in that case, Facebook authData. The flow then should be as following:
|
@flovilmart ok it's working now. It creates the user on first time log in, and just update when the user tries to login later. This is the return data
And the authData is now being saved on mongodb
Ok, one last question so I can do more testing locally, how can I set on config.json to load the cloud files? I'm trying like this but it's not working: "cloud": "./cloud/main.js" |
Try to pass the full path to your CloudCode relative paths are kinda a pain... I may propose a fix for that for the path relative to your configuration file. |
@flovilmart, I think this is the problem related: parse-community/Parse-SDK-Android#350. As you can see, how they describe is exactly what my tests tries to show. And they say that the same code works with official parse. There is another issues with android and anonymous user, that can be related, like this one, but I'm not sure: parse-community/Parse-SDK-Android#401 |
After looking at the logs, this should be fixed by the PR just referenced here. |
I'm testing again with enableAutomaticUser set to true on client. And now the _auth_data_facebook is not being saved back on mongodb, and therefore is back to creating new user every time. I've re-checked the code again to see if I've done something different, but for now I can only assume is the enableAutomaticUser. |
@weengo did you update to 2.1.6? |
yep, still the same issue |
I've now tried on aws, also with the 2.1.6 updated version, and it worked. |
are you sure your local npm is not linked with npm link, I recall we tried that at one point. |
It might be that then. I'm gonna reset locally and try again |
yep, my bad, I was still on branch flovilmart.OAuthImprovements, have moved back to master and all is fine now |
@weengo did you anything different in index.js to allow new Facebook user to login. i have iOS app which use Facebook login to sign up. But new user cannot sign up also old users that i had on parse can login after moving to heroku parse server. i would really appreciate the help. |
Hi @arpit529, nothing different, did you set your fb id on facebookAppIds: ['xxxxxx'] ? To be of a better help, you may want to post your index.js code here, covering your sensitive data. I'm also running on an iOS app. Sign up and login are working, but there's one exception I've found: before the migration, I had an user with both username/password login and facebook linked, later this user have decided to unlink the facebook and only keep the username/password login. So, after the migration this user wasn't able to login again. To correct that I had to remove the column "facebook": null from the_User collection on mongodb. I'd recommend you run your app again with VERBOSE=1, and post here the errors that you've found. |
where was that column facebook: null ? was it _auth_data_facebook ? |
On _User collection. Yes, I think was something like this.
Can't reproduce again because I've already past migration. |
ok, I'm looking into it |
@weengo Thanks for quick response. _index.js_******** var express = require('express'); var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI; if (!databaseUri) { var api = new ParseServer({ var app = express(); // Serve the Parse API on the /parse URL prefix // Parse Server plays nicely with the rest of your web routes var port = process.env.PORT || 1337; |
@arpit529, index looks ok. Could you run your app on VERBOSE=1 and send us the log? Would be better to see how the server and your app are communicating. |
Issue
Every time I try to login through facebook a new user is created on mongo. I've also noticed there's no column _auth_data_facebook saved on these users.
Prerequisites
Steps to reproduce on Android
Log from Verbose
Here we can see that authData is sent through POST
Possible Similar Issues
The text was updated successfully, but these errors were encountered: