Skip to content

ParseFacebookUtils.isLinked(user) returning false after executing query with 'user' key included #269

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

Closed
SobanMahmood opened this issue Nov 26, 2015 · 12 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@SobanMahmood
Copy link

I have Parse object named 'Activity' on back end, which has a pointer to 'User' object.
In my android app, after logging in or linking through ParseFacebookUtils, if I made a parse query on 'Activity' and include key 'user' to that query for fetching users' details, then ParseFacebookUtils.isLinked(ParseUser.getCurrentUser()) starts returning false after that query. However if I kill android app and relaunch it, then ParseFacebookUtils.isLinked(ParseUser.getCurrentUser()) starts returning true again. It seems as for some reason some cached data is getting affected after making query with 'user' key included. This does not happen if query is made without including key 'user'.
This happens if at least one of the fetched 'Activities' has current logged in user set as the 'user' pointer.

@SobanMahmood
Copy link
Author

Sdks I am using are as following:
com.facebook.android:facebook-android-sdk:4.6.0
com.parse:parsefacebookutils-v4-android:1.10.3@aar
com.parse:parse-android:1.10.3

@parse-github-bot
Copy link

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

@wangmengyan95
Copy link
Contributor

Hi @SobanMahmood, do you use the local datastore in your app?

@SobanMahmood
Copy link
Author

Hi @wangmengyan95 , thanks for the response.
Yeah, I am using local datastore in my app.
Please let me know if any other info is required.

@wangmengyan95 wangmengyan95 self-assigned this Dec 1, 2015
@wangmengyan95
Copy link
Contributor

Hi @SobanMahmood, another question I want to know is whether you use the local datastore all the time? All the time means when you log in or link with Facebook and do the query, the local datastore is always enabled. I assume this is your case, but I just want to make sure, since we have some migration step when you first enable local datastore. I want to narrow down the scope. Thanks.

@SobanMahmood
Copy link
Author

@wangmengyan95 yeah, Local datastore is always enabled in my case. In fact it is enabled at start of the application in overridden method onCreate() of extended Application class.

@wangmengyan95 wangmengyan95 added type:bug Impaired feature or lacking behavior that is likely assumed and removed needs more info labels Dec 4, 2015
@wangmengyan95
Copy link
Contributor

Hi @SobanMahmood, I can repo this issue. It seems a valid bug. I will try to figure out why this happen. Thanks for opening this issue! Right now I am not sure whether it is a bug of Parse or ParseFacebookUtils. If it is a bug of ParseFacebookUtils, I will create a new issue in ParseFacebookUtils and close this one.

@wangmengyan95
Copy link
Contributor

I find the cause of this issue. When you login, we keep an in-memory and in-disk currentUser object. When you query a ParseUser, the server will not include the authData for security reason. For you case, if you include the user key, when we get the response and try to decode it, we will try to use the incomplete data to rebuild the user. If the user is the currentUser, we will use the new-build user which is incomplete to overwrite the in-memory currentUser. That's why the ParseFacebookUtils.isLinked(ParseUser.getCurrentUser()) will return false. However, since we do not change the in-disk currentUser, when you relaunch the app, we read the currentUser from disk and ParseFacebookUtils.isLinked(ParseUser.getCurrentUser()) return the true result.
My current solution for this is to change the third parameter here, since if the Object is a _User object, we can not guarantee it is complete. But I am not 100% sure it is safe to do this. Any thoughts? @grantland

@SobanMahmood
Copy link
Author

Hi @wangmengyan95, thanks for the support. I hope this issue will get fixed in next release. Until then, is there any work around possible with the current version?

@wangmengyan95
Copy link
Contributor

Hi @SobanMahmood, one possible solution is after you do this kind of query, you manually fetch the currentUser by calling ParseUser.getCurrentUser().fetchInBackground(); or ParseUser.getCurrentUser().fetch(); (depends on whether you want to use the async or sync version). Then the currentUser should contain the authData.

@grantland
Copy link
Contributor

@SobanMahmood
Copy link
Author

Thanks @wangmengyan95 for the work around, that seems simple, I hope this will do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

4 participants