-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Sharing multiple connections #4084
Sharing multiple connections #4084
Conversation
@@ -118,6 +121,17 @@ public void onResume() { | |||
setNavigationIcon(R.drawable.ic_close_white_24dp); | |||
} | |||
|
|||
private void clearCookies() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct in thinking removeAllCookies()
will affect every WebView in the app? If so, this might be a problem since it would force the user to re-login to any authenticated page they visited in the app.
Also, keep in mind that clearing cookies is asynchronous, so it's possible that the cookies won't be cleared before the page is browsed. If this is a concern, you may want to flush the cookie manager before browsing (keeping in mind that's a blocking call).
One final nit: this seems like it belongs in a utility class since it's not tied to the publicize feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct in thinking removeAllCookies() will affect every WebView in the app? If so, this might be a problem since it would force the user to re-login to any authenticated page they visited in the app.
Yup, you're right. I like your emphasis on might because I went through the same thought process. I believe it is ok because I don't see too many use cases where someone has navigated far beyond WordPress-related content. And since with WordPress-related content we are passing the credentials in anyway, they'll always be logged-in.
Also, keep in mind that clearing cookies is asynchronous, so it's possible that the cookies won't be cleared before the page is browsed. If this is a concern, you may want to flush the cookie manager before browsing (keeping in mind that's a blocking call).
Good call. I'll move it to when the WebView closes (like iOS does)
One final nit: this seems like it belongs in a utility class since it's not tied to the publicize feature.
That's fair. I'll create (I couldn't find one) a WebViewUtils class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I'll move it to when the WebView closes (like iOS does)
Sorry, didn't finish my thought there. If it's at the end, it will solve the async issue of the webview showing up before the cookies are cleared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to clear cookies from specific domains rather than clear them all? If so, this may help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that method (and many other similar methods) and unfortunately it doesn't seem to actually work. Setting a cookie doesn't actually overwrite it. It looks like people have had mixed results with different versions of Android.
Because of all of this I believe we should keep the deletion of all cookies.
Prior to testing this PR, I already had a test Twitter account setup with publicize. Using this PR, I attempted to add a second Twitter account. I got all the way through the process, but when I was returned to the publicize detail I saw a toast stating "an error occurred" and the second Twitter account didn't appear. The log shows "Unexpected response code 400 for https://public-api.wordpress.com/rest/v1.1/sites/52451176/publicize-connections/new" I tried again with the same result, and it occurs in both the emulator and on a real device. Note that this 2nd Twitter account has "verify login requests" enabled, which required having Twitter send me a verification code in order to login with the app. I disabled this setting, but the problem still occurred. |
Well that's thoroughly confusing... That's not on the list of errors for that endpoint https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/publicize-connections/new/#apidoc-resource-errors |
Addressed in d4efbf9 |
@kwonye Just in case you weren't aware, this is currently failing Travis. |
@nbradbury ready for a second pass. I've created #4089 where we can address design issues we find. |
Hmm, something's very broken here. I have a test Twitter account named
Then I connected my Just to be clear, this is what I saw after I disconnected |
@nbradbury I'm in the state of your "Unexpected response code 400" error that you saw. Unfortunately the ServerError is null. Still unable to repro the incorrect Twitter account showing, but gun to my head I'm guessing they're related. I'll continue investigating and ping you once this is ready to review again, thanks 👍 |
Ok @nbradbury ready for another pass! Multi-users show the correct selection dialog now. |
…Fragment to deal with rotation
When I attempted to connect a Twitter account, I saw the dialog below which incorrectly says I'm connecting Facebook. The description is cut off, as is the list of connected users (and I'm not sure why that list is even shown here). I also don't understand why "Nick Bradbury" is listed four times, nor why it's even in the list (I don't have a Twitter account named "Nick Bradbury"). When I canceled that dialog, I saw a toast that once again mentioned Facebook even though it was a Twitter account. |
@nbradbury thanks for that, we weren't properly filtering out the different services. It's been resolved 👍 |
@nbradbury unfortunately we do not get the information that tells us which account the user requested. We just get a list of all the connections available, and that dialog shows the ones that are not connected yet. The web has to do this as well unfortunately. |
I just pulled the latest changes, and now I'm getting a
This occurs when the app navigates away from Twitter's "Redirecting you back to the application" page. |
Thanks @nbradbury, that was a typo on my part. I was pulling the wrong resource ID. It works now. |
Fixes #4071
To test:
Add multiple accounts to a single connection and post. It should post to the multiple accounts correctly.
Also, disconnect accounts to verify updates to accounts are correct.
Needs review: @nbradbury