Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Login in the sync page #135

Merged
merged 10 commits into from
Nov 10, 2015
Merged

Login in the sync page #135

merged 10 commits into from
Nov 10, 2015

Conversation

shana
Copy link
Contributor

@shana shana commented Oct 26, 2015

Fixes #57

If the current repository is a github/github enterprise repo but the user isn't logged in to its instance, then network git operations might fail. Show a warning on the Sync page if this is the case, and allow the
user to login from there.

Fixes #57

If the current repository is a github/github enterprise repo but the
user isn't logged in to its instance, then network git operations might
fail. Show a warning on the Sync page if this is the case, and allow the
user to login from there.
@haacked
Copy link
Contributor

haacked commented Oct 26, 2015

Very nice! I tried this out with a github.com repository and it worked great. However, I tried it with a GitHub Enterprise repository and it didn't work. Here's the steps I took.

  1. Log out of both GitHub.com and GitHub Enterprise.
  2. Open a solution that has its remote pointing to a GitHub Enterprise instance.
  3. Go to the Sync tab.

Expected: An error that shows I'm not logged into the GitHub Enterprise instance corresponding to the remote.
Actual:

Note that the tooltip says "api.github.com". It should probably have the domain of the GitHub Enterprise instance. When I click "Login" it launched the login dialog, but the dialog had "GitHub" selected instead of GitHub Enterprise.

return cm.Connections.ToObservable()
.Where(c => c.HostAddress.Equals(address))
.SelectMany(c => c.Login())
.Select(c => hosts.LookupHost(c.HostAddress)).Any(h => h.IsLoggedIn);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think putting the .Any(...) call here on a new line aligned with .Where .SelectMany and Select would be more consistent with how we chain methods elsewhere.

@haacked
Copy link
Contributor

haacked commented Oct 26, 2015

🍨

@shana
Copy link
Contributor Author

shana commented Oct 27, 2015

Looks like our detection of enterprise instances when not authenticated was not quite correct. Now it should correctly detect them, the message should use the correct domain name and the home page should show the information about the repository if it's an enterprise instance repo (when not logged in).

@shana
Copy link
Contributor Author

shana commented Oct 27, 2015

When I click "Login" it launched the login dialog, but the dialog had "GitHub" selected instead of GitHub Enterprise.

There's no way right now of telling the login dialog which tab to show. That's going to take a bigger change of how we instantiate views in general (to pass contextual information to them), and I need to do that for the PR views as well (part of the UIController refactor I'm doing), so I'll fix that once I have a system to do it properly in place.

@shana shana assigned haacked and unassigned shana Oct 27, 2015
// it'll throw if it's private or an enterprise instance requiring authentication
catch (ForbiddenException)
{
if (!HostAddress.IsGitHubDotComUri(OriginalUrl.ToRepositoryUrl()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Flow analysis seems to think OriginalUrl could be null. However, it looks to me that's not legitimate. So maybe add an Assert here that it's not null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, flow analysis is completely wrong here, this exception can only be thrown inside the condition that guarantees that OriginalUrl is not null (and OriginalUrl is readonly it's impossible for it to be changed in a way that makes it non-null to go into the condition and null in the catch block). I'm doing some changes to the constructor so this it not an issue anymore.

@shana
Copy link
Contributor Author

shana commented Oct 28, 2015

I've fixed things up and this branch is totally 💯 ready! ✨

@haacked
Copy link
Contributor

haacked commented Oct 28, 2015

I tested it with a GitHub Enterprise repository and it still doesn't work for me.

@shana
Copy link
Contributor Author

shana commented Oct 28, 2015

Do you get information about the repo on the team explorer home page when you're not logged in? I've tried with garage and with a test enterprise instance, what instance are you trying with? Maybe there's something different about the instance you're using that's tripping the check wrongly.

@haacked
Copy link
Contributor

haacked commented Oct 28, 2015

Do you get information about the repo on the team explorer home page when you're not logged in?

Nope. Just the basic Git stuff.

I've tried with garage and with a test enterprise instance, what instance are you trying with? Maybe there's something different about the instance you're using that's tripping the check wrongly.

I'm trying with a repo in our internal GitHub Enterprise instance. You know the one. 😄

@shana
Copy link
Contributor Author

shana commented Nov 3, 2015

Ok, there's some creepy threading action going on which is making things not load properly. Fixicating...

@shana
Copy link
Contributor Author

shana commented Nov 9, 2015

@haacked Ok, fixed it. Looks like different enterprise instances throw different types of exceptions when you're not logged in, and the exception I was catching was a little too specific.

@haacked
Copy link
Contributor

haacked commented Nov 10, 2015

Ok, I'll test this right now.

@haacked
Copy link
Contributor

haacked commented Nov 10, 2015

There's no way right now of telling the login dialog which tab to show. That's going to take a bigger change of how we instantiate views in general (to pass contextual information to them), and I need to do that for the PR views as well (part of the UIController refactor I'm doing), so I'll fix that once I have a system to do it properly in place.

Ok, I'll log a separate issue for this.

Also, I noticed that after I logged in, the message didn't automatically go away. And if I log out and then go back to the Sync button, I don't see the message. I'll log separate issues for that too. I think the current behavior is good enough for now.

haacked added a commit that referenced this pull request Nov 10, 2015
@haacked haacked merged commit 155aae0 into master Nov 10, 2015
@haacked haacked deleted the feature/login-on-sync-page branch November 10, 2015 18:52
@haacked
Copy link
Contributor

haacked commented Nov 10, 2015

thumbs-up-phil-dunphy

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants