You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Signin: Prompt if signing in to wpcom via self-hosted form, if already a wpcom acct in the app. #5166
The self-hosted signin form will allow a user to enter credentials and URL to a wpcom site, and authenticate accordingly. This is fine if there is not currently a default wpcom account in the app but could be problematic otherwise.
Lets add a check for an existing default wpcom account and prompt the user they should first sign out of it.
@aerych Any ideas how we check for this? It looks like fetchSiteInfo in LoginSiteAddressViewControllermay only return site info for .com sites or Jetpack sites?
Yep, fetchSiteInfo ends up querying BlogServiceRemoteRest.fetchSiteInfoForAddress which checks the /sites/site REST API endpoint, which returns information only for .com and connected Jetpack sites.
I think checking AccountService.defaultWordPressComAccount plus checking the results of fetchSiteInfo would be enough?
No. If the call to the /sites/site endpoint indicates the user has entered a WordPress.com site, and AccountService.defaultWordPressAccount returns an existing account in the app then we'd prompt the user instead of continuing with the login flow.
Hey @aerych , I've been looking into this for some time now. Your suggestion sounds great but I am not sure how to inquire about the defaultWordPressComAccount from AccountService inside WordpressAuthenticator classes. Any thoughts?
Oh. Right. AccountService isn't part of the pod. 🤦♂️. I'm sorry, that should have occurred to me. In my defense the last time I didn't anything significant with login it was before it was a pod 😬.
The pod complicates things a little but I think this is still possible. We might try something like this:
In the pod, add a new optional method to the WordPressAuthenticatorDelegate protocol to check for an existing default wpcom account (if one exists). This can probably just be a bool type.
In the app, update WordPressAuthenticationManager to implement that method return true or false depending on the value of AccountService.defaultWordPressComAccount
Then, back in the pod, we could call the method via WordPressAuthenticator.shared.delegate and handle accordingly.
I think that is viable. 🤔
Summoning @nheagy to this thread cos he might have some good insights as well.
Also @mindgraffiti as this might be relevant to Woo in the future.
I don't have anything to add, @aerych. That sounds like the right solution. My only suggestion would be to make the delegate method named such that it suggestions if an wpcom account can login, vs. whether one already exists. That way if we add multiple account support one day it will still work.
Ok so I added the check for defaultWordPressComAccount in AccountService. It checks for the existence of defaultWordPressComAccount in userDefaults. That value is removed upon logout and is always nil at the point where fetchSiteInfo successfully comes back so I'm not sure how you meant it to be used. At that point I don't have an account or anything about the user.
Benn digging in this all day and maybe I misunderstood but I don't see how we can do this without having the user login and then checking.
Any thoughts? @aerych , @nheagy
cc: @kwonye
I'm realizing that me from 3 years ago probably should have included steps to reproduce the problem in the issue description. Sorry @yaelirub. We have a lot of log in flows and if we get any more I think a map and compass might be needed to navigate them all. 😬
I bet you've testing by going through the full log in flow from a logged out state? If so, try this:
Start by being signed in to a WordPress.com account.
Go to the My Sites tab and view the list of sites.
Tap the + button in the nav bar and choose "Add self-hosted site"
On the site address screen, enter the URL for a WordPress.com site that does not belong to the WordPress.com account that's currently logged into the app.
On the next screen, enter the WordPress.com credentials for the account that owns the site at the URL entered on the previous screen.
What should happen at this point is the existing WordPress.com account is removed form the app and replaced by the account that was just signed into. It can be a confusing scenario. A user might wonder where all their other blogs went. Hence the desire to prompt them to sign out first.
WCiOS requires all self-hosted users to be connected via Jetpack, which means they must use WP.com credentials. So the only thing that might affect Woo in the future is what @nheagy already said, about handling multiple account support.
Activity
ScoutHarris commentedon Jun 19, 2018
With the login refactor, this is no longer possible.
ScoutHarris commentedon Jun 19, 2018
Gah! I misread the description.
frosty commentedon Jan 10, 2019
@aerych Any ideas how we check for this? It looks like
fetchSiteInfoinLoginSiteAddressViewControllermay only return site info for .com sites or Jetpack sites?aerych commentedon Jan 10, 2019
Yep,
fetchSiteInfoends up queryingBlogServiceRemoteRest.fetchSiteInfoForAddresswhich checks the/sites/siteREST API endpoint, which returns information only for .com and connected Jetpack sites.I think checking
AccountService.defaultWordPressComAccountplus checking the results offetchSiteInfowould be enough?yaelirub commentedon Jan 10, 2019
@aerych , @frosty , Would we still have to login the user?
aerych commentedon Jan 10, 2019
No. If the call to the
/sites/siteendpoint indicates the user has entered a WordPress.com site, and AccountService.defaultWordPressAccount returns an existing account in the app then we'd prompt the user instead of continuing with the login flow.yaelirub commentedon Jan 10, 2019
Got it! Thanks!
yaelirub commentedon Jan 17, 2019
Hey @aerych , I've been looking into this for some time now. Your suggestion sounds great but I am not sure how to inquire about the defaultWordPressComAccount from AccountService inside WordpressAuthenticator classes. Any thoughts?
aerych commentedon Jan 17, 2019
Oh. Right.
AccountServiceisn't part of the pod. 🤦♂️. I'm sorry, that should have occurred to me. In my defense the last time I didn't anything significant with login it was before it was a pod 😬.The pod complicates things a little but I think this is still possible. We might try something like this:
WordPressAuthenticatorDelegateprotocol to check for an existing default wpcom account (if one exists). This can probably just be abooltype.WordPressAuthenticationManagerto implement that method return true or false depending on the value ofAccountService.defaultWordPressComAccountWordPressAuthenticator.shared.delegateand handle accordingly.I think that is viable. 🤔
Summoning @nheagy to this thread cos he might have some good insights as well.
Also @mindgraffiti as this might be relevant to Woo in the future.
yaelirub commentedon Jan 18, 2019
That Gif is just brilliant! Can't stop looking at it 😂
nheagy commentedon Jan 18, 2019
I don't have anything to add, @aerych. That sounds like the right solution. My only suggestion would be to make the delegate method named such that it suggestions if an
wpcomaccount can login, vs. whether one already exists. That way if we add multiple account support one day it will still work.yaelirub commentedon Jan 19, 2019
Ok so I added the check for defaultWordPressComAccount in AccountService. It checks for the existence of defaultWordPressComAccount in userDefaults. That value is removed upon logout and is always nil at the point where fetchSiteInfo successfully comes back so I'm not sure how you meant it to be used. At that point I don't have an account or anything about the user.
Benn digging in this all day and maybe I misunderstood but I don't see how we can do this without having the user login and then checking.
Any thoughts? @aerych , @nheagy
cc: @kwonye
aerych commentedon Jan 19, 2019
I'm realizing that me from 3 years ago probably should have included steps to reproduce the problem in the issue description. Sorry @yaelirub. We have a lot of log in flows and if we get any more I think a map and compass might be needed to navigate them all. 😬
I bet you've testing by going through the full log in flow from a logged out state? If so, try this:
What should happen at this point is the existing WordPress.com account is removed form the app and replaced by the account that was just signed into. It can be a confusing scenario. A user might wonder where all their other blogs went. Hence the desire to prompt them to sign out first.
Hoping this helps!
yaelirub commentedon Jan 19, 2019
Oh wow! This is super helpful.
That's a completely different flow than what I was investigating!
mindgraffiti commentedon Jan 23, 2019
WCiOS requires all self-hosted users to be connected via Jetpack, which means they must use WP.com credentials. So the only thing that might affect Woo in the future is what @nheagy already said, about handling multiple account support.