-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
User is always being detected as new when logged in through Facebook, Twitter, or Google #7737
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
Thanks for opening this issue!
|
Can you please correct your example code and provide a full example to reproduce the issue, including user creation. |
@mtrezza
from the client-side this is a an example of Twitter login
From the client-side when a user is already signed up it performs the required action as the user isn't new but from the server-side there is the issue I opend. |
Since you say this is a server issue, are you able to reproduce this solely in Cloud Code (or via the REST API) without using the client? That way you could add a failing test and we can exclude the client as a source of error. |
@mtrezza is it possible to perform twitter or google login using REST API or in cloud code? if yes, how so I can test it. what made me think that it's a problem from the server side is when I change the information of a normal user from the client-side and save it from the client it's working correctly. also when using (all 3 alternative login methods Facebook, Twitter, and Google) the problem occurs but not with a normal account. |
In Cloud Code you would do it like you'd do it using the Parse JS SDK. |
I tried Facebook login with the Parse JS SDK, the same issue occurs. Tried to run a fail test but I keep getting this error
|
Could you open a PR with the failing test that demonstrates the issue? |
@mtrezza sure I would like to do that, I even tried to do it check my previous comment, I keep getting the same error any idea on how to proceed? |
try to use |
even when I don't edit anything (trying to run a test over the cloned repo without modification) and try to run a test i get the same error, when I try to run a test on a specific file I get the following error
I had the same issue when I published last time a failing test but it did work when I used npm run coverage, for some reason, it's not working now. |
Not sure but it may be that running the test on a windows platform is causing issues. The error seems to say that mongorunner does not have a MongoDB 4.4.10 version for win32. You could try to use a different MongoDB version to run the test. That could also explain why you could run As you can see in
You can run any other DB version with Then just change the test from |
The issue still persists I have tried multiple versions, I even tried it on Linux but get almost a similar error "can't determine Linux flavor" problems maybe from the package side or some missing files? |
Not sure, but it look much like an issue of your custom environment, as running tests is a basic functionality. Try to delete the node_modules folder, but other than that I am not sure how to support any further at this point. I am closing this as it does not seem to a bug in Parse Server but a custom code / environment issue and it was not possible to demo the issue. We can re-open the issue once we have more info. |
The issue should be reopened, managed to get the test working and created a pull request for it -> #7742 |
Any update or confirmation? |
This might be related to parse-community/Parse-SDK-JS#1353 (comment). Much of the handling of Note the issue in my comment above as in your PR, you mentioned you tested with the JS SDK. There's a bug as the JS SDK doesn't always handle |
@cbaker6 the issue also happens with the Android SDK, and something I forget to mention is that I am not using anonymous login and also not trying to link the user, it happens when a user signs up/reconnect with the third party auth used. if it's an issue with the session token it might get worst if the user tries to log in with multiple devices. |
Looking at the history of the ParseUser file in the Android SDK it hasn't had much feature additions/fixes since 2018 (most of the changes look to be linting and clean up) so it's possible the SDK can have a bug. The anonymous login discussion is an example of how the client SDKs handle auth data... If your cloud code triggers are simple enough and you can help me understand the process you are making to test. I should be able to replicate the behavior with the Swift SDK to help figure out if it's a server or client issue. |
@cbaker6 Sure, just sign up -> log out -> reconnect with the account the same account from the client side, from the cloud side you can just do a random test in the user's beforeSave where you check if the user is new (you can just try console.log to print a message) and in the afterSave check if the request.original is being retrieved. |
This is an issue I had when I created my own auth provider (custom 2fa), and when ever users login using that auth provider an after save triggers for the user as a newly created user, my workaround was to create a lock object when the user is created in beforeSave so when after save I check if that lock exists then yes it is a new user otherwise it is this bug. in before save if(!!req.original){ // signup create a lock object for this user
const lockObject = new Parse.Object("NewUserLockObject");
lockObject.set(ParseUserKeys.username, username, {});
await lockObject.save(null, {useMasterKey: true});
} then in after save // New signup
/// This is a workaround for a bug in Parse Server
// When using custom AuthAdapter is being used after login saves authData in the use object
// But it makes an after save trigger without a before save ?
// this makes the req argument have no original in after save
// so the workaround is to query the DB for an existing user with the same username
// if this object has been created then it is signup otherwise it is just the bug
// check the existence of a lock object it is there then this is a signup if it is not it is just the bug
const exists = await QueryUtils.findOneInClassForKeyEqual(Parse.Object.extend("NewUserLockObject"), ParseUserKeys.username, req.object.get(ParseUserKeys.username), true);
if (!req.original && exists) {
// delete the lock file
await exists.destroy({useMasterKey: true});
// perform actions fir signup...
I know this is not the best solution but I was low on time |
@cbaker6 can you confirm it on your side? |
The discussion seems to ping-pong between Parse Server, Parse JS SDK and Parse Android SDK. Is there a way to reproduce the issue with a test in this repository without involving the Parse Android SDK? |
I have already made a pull request for a failing test #7742 |
@Meglali20 I confirm the issue yes I had this issue for s year now and I used that workaround because I did not know any other solution, every release I check if it was fixed but no luck I think the issue is somewhere in the custom auth providers implementation but I am really not familiar with parse under the hood so I can't ping point it. but I think this is definitely a bug that has nothing to do with the client SDK but rather somewhere in the auth provider implementation |
New Issue Checklist
Issue Description
-A user is being detected as new when he isn't.
-authData field being deleted for unknown reasons.
Steps to reproduce
Add the following code to the cloud code and try to login using Facebook, Twitter, or Google.
Actual Outcome
This issue leads to performing unwanted actions over a non new user.
After a user performs a login/signup through Facebook, Twitter, or Google, the user is always being detected as a new user in afterSave.
When checking again in the database you can see that the same user has just logged in and it's not a new one,
Noticed also something with the authData field, when testing login with different methods the authData is being erased(doesn't happen all the time).
Expected Outcome
Not detect a user as a new one when he isn't.
Environment
Server
[email protected]
Windows 10
Local
Database
MongoDB
FILL_THIS_OUT
MongoDB Atlas
Client
Android
1.26.0
Logs
The text was updated successfully, but these errors were encountered: