Skip to content
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

First pass at fixing RestClientCallback for getRestClient() #2315

Closed
wants to merge 1 commit into from

Conversation

gkotula
Copy link
Contributor

@gkotula gkotula commented May 23, 2022

Opening this for feedback on the solution for this issue. Mainly, I am unsure how this may affect complex login flows including IDP and user switching in all customer use-cases.

The issue: forcedotcom/SalesforceMobileSDK-ReactNative#247

Original PR that introduced the issue: #2203

The core problem is that launching the Login Activity from Intent does not get the callback for when the RestClient is ready, but we cannot use AccountManager.addAccount(...) since users may not have permission to add through the Android framework's AccountManager.

Luckily, AccountManager has an API for listening for changes to the accounts on the device, but care must be taken to properly remove the listener after the callback is invoked so as not to leak Activities.

@gkotula gkotula self-assigned this May 23, 2022
* Callback from either user account creation, or a call to getAuthToken, used
* by the Android account management components.
*/
private class AccMgrCallback implements AccountManagerCallback<Bundle> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused.

@mobilesdk-bot
Copy link

mobilesdk-bot commented May 23, 2022

1 Warning
⚠️ No Lint Results.

Tests results for SalesforceSDK

Generated by 🚫 Danger

@gkotula
Copy link
Contributor Author

gkotula commented May 25, 2022

Closing due to edge case discovered while testing that would leak the account change listener if the LoginActivity is finished without modifying the accounts (e.g. if the user clicks back and the Activity pops from the task stack)

@gkotula gkotula closed this May 25, 2022
@bhariharan
Copy link
Contributor

@gkotula I'd prefer to leave the login code as-is for now. There are many different flows that need to be accounted for.

@gkotula gkotula deleted the bugfix/rest-client-callback branch June 1, 2022 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants