Skip to content

Signin: Prompt if signing in to wpcom via self-hosted form, if already a wpcom acct in the app. #5166

Closed

Description

@aerych

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.

Activity

  1. added this to the Pending milestone on Apr 19, 2016
  2. ScoutHarris commented on Jun 19, 2018

    @ScoutHarris
    Contributor

    The self-hosted signin form will allow a user to enter credentials and URL to a wpcom site

    With the login refactor, this is no longer possible.

  3. ScoutHarris commented on Jun 19, 2018

    @ScoutHarris
    Contributor

    Gah! I misread the description.

  4. frosty commented on Jan 10, 2019

    @frosty
    Contributor

    @aerych Any ideas how we check for this? It looks like fetchSiteInfo in LoginSiteAddressViewController may only return site info for .com sites or Jetpack sites?

  5. aerych commented on Jan 10, 2019

    @aerych
    ContributorAuthor

    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?

  6. yaelirub commented on Jan 10, 2019

    @yaelirub
    Contributor

    @aerych , @frosty , Would we still have to login the user?

  7. aerych commented on Jan 10, 2019

    @aerych
    ContributorAuthor

    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.

  8. yaelirub commented on Jan 10, 2019

    @yaelirub
    Contributor

    Got it! Thanks!

  9. yaelirub commented on Jan 17, 2019

    @yaelirub
    Contributor

    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?

  10. aerych commented on Jan 17, 2019

    @aerych
    ContributorAuthor

    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.

  11. yaelirub commented on Jan 18, 2019

    @yaelirub
    Contributor

    That Gif is just brilliant! Can't stop looking at it 😂

  12. nheagy commented on Jan 18, 2019

    @nheagy
    Contributor

    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.

  13. yaelirub commented on Jan 19, 2019

    @yaelirub
    Contributor

    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

  14. aerych commented on Jan 19, 2019

    @aerych
    ContributorAuthor

    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.

    Hoping this helps!

  15. yaelirub commented on Jan 19, 2019

    @yaelirub
    Contributor

    Oh wow! This is super helpful.
    That's a completely different flow than what I was investigating!

  16. mindgraffiti commented on Jan 23, 2019

    @mindgraffiti
    Contributor

    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.

  17. removed this from the Pending milestone on Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions