Also, adopt the new name of the fork more precisely so it's reflected in
the new remote URL. The name of the new git remote is for now *not*
inherited from the returned Repository object for backwards compatibility.
Fixes#1178
When looking up an existing hub token among user's authorizations, be
sure to fetch all results by following pagination links. Previously we
just stopped at the 1st page, and if the token for hub didn't appear
there we would try to create it, which would result in a 422 validation
error if it already existed.
References 1e4477b566Fixes#531, fixes#558, fixes#563
For people who are using hub for a longer time now, hub has stored an OAuth
token in Authorizations API with a `note_url` value that is now outdated
(e.g. "http://defunkt.io/hub/"). The newer `oauth_app_url` doesn't match
that, so the token is not reused. Hub tries to create a new OAuth token
with a `note` that says "hub" which fails with a 422 because it already
exists.
This fixes reusing old OAuth tokens even if the `note_url` doesn't match
anymore. Any key with `note` that says "hub" will get reused.
Fixes#496
Technically, they're going to be the same values for OAuth tokens
created via the API, but since we write to `note_url` field it makes
sense to use the same field to read the value back, for consistency.
hub initially tries to fetch user's existing OAuth token for hub if it
exists, and will prompt the user for a 2FA code. However those who
receive it via SMS would never get the code since a GET to GitHub's
Authorizations API purposely doesn't trigger an SMS. There's some
discussion as to whether this is an API bug for not, but in the
meantime, make a dummy POST request for the sole reason of triggering
the SMS.
Fixes#412, closes#435, closes#445
API authentication and persisting of credentials in Config was
convoluted and inflexible, and it wasn't possible to log in with
different credentials than your GitHub screen name. Since Enterprise
supports different authentication schemes, it's important to allow
emails for login as well (or any string for that matter) and retrieve
the user's screen name after successful authentication.
This also improves handling special characters in Basic Auth usernames
and passwords.
Fixes#407
This ensures we end up with the correct capitalization of user's login
name, and gives the opportunity to the server to change the project name
without having us choke on it.
Fixes#263
I tried to hack Sinatra to automatically serialize non-string response
bodies as JSON, but this is not straightforward due to sinatra/sinatra#512
and doesn't really work in a whole lot of edge-cases.
Introduced a simple `json` helper and now using that instead of `body`.