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

Commit b4a400b

Browse files
Merge branch 'master' into essentials-publish
2 parents 2aa0881 + 4bd5541 commit b4a400b

26 files changed

+116
-48
lines changed

src/GitHub.Api/IOAuthCallbackListener.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ public interface IOAuthCallbackListener
1616
/// <param name="cancel">A cancellation token.</param>
1717
/// <returns>The temporary code included in the callback.</returns>
1818
Task<string> Listen(string id, CancellationToken cancel);
19+
20+
/// <summary>
21+
/// Redirects the last context to respond with listen and stops the underlying http listener
22+
/// </summary>
23+
/// <param name="url">Url to redirect to.</param>
24+
void RedirectLastContext(Uri url);
1925
}
2026
}

src/GitHub.Api/LoginManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public async Task<LoginResult> LoginViaOAuth(
157157
await keychain.Save("[oauth]", token.AccessToken, hostAddress).ConfigureAwait(false);
158158
var result = await ReadUserWithRetry(client).ConfigureAwait(false);
159159
await keychain.Save(result.User.Login, token.AccessToken, hostAddress).ConfigureAwait(false);
160+
oauthListener.RedirectLastContext(hostAddress.WebUri.Append(result.User.Login));
161+
160162
return result;
161163
}
162164

src/GitHub.App/Services/OAuthCallbackListener.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.ComponentModel.Composition;
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using System.Diagnostics;
24
using System.Net;
35
using System.Threading;
46
using System.Threading.Tasks;
@@ -39,6 +41,7 @@ public OAuthCallbackListener(IHttpListener httpListener)
3941
}
4042

4143
public readonly static string CallbackUrl = Invariant($"http://localhost:{CallbackPort}/");
44+
private IHttpListenerContext lastContext;
4245

4346
public async Task<string> Listen(string id, CancellationToken cancel)
4447
{
@@ -51,22 +54,29 @@ public async Task<string> Listen(string id, CancellationToken cancel)
5154
{
5255
while (true)
5356
{
54-
var context = await httpListener.GetContextAsync().ConfigureAwait(false);
55-
var foo = context.Request;
56-
var queryParts = HttpUtility.ParseQueryString(context.Request.Url.Query);
57+
lastContext = await httpListener.GetContextAsync().ConfigureAwait(false);
58+
var queryParts = HttpUtility.ParseQueryString(lastContext.Request.Url.Query);
5759

5860
if (queryParts["state"] == id)
5961
{
60-
context.Response.Close();
6162
return queryParts["code"];
6263
}
6364
}
6465
}
6566
}
66-
finally
67+
catch(Exception)
6768
{
6869
httpListener.Stop();
70+
throw;
6971
}
7072
}
73+
74+
public void RedirectLastContext(Uri url)
75+
{
76+
lastContext.Response.Redirect(url);
77+
lastContext.Response.Close();
78+
79+
httpListener.Stop();
80+
}
7181
}
7282
}

src/GitHub.Resources/Resources.cs-CZ.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>Klon</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>Přidat nebo změnit účty</value>
893893
</data>
894894
</root>

src/GitHub.Resources/Resources.de-DE.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>Klonen</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>Konten hinzufügen/ändern</value>
893893
</data>
894894
</root>

src/GitHub.Resources/Resources.es-ES.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>Clonar</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>Agregar o cambiar cuentas</value>
893893
</data>
894894
</root>

src/GitHub.Resources/Resources.fr-FR.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ https://git-scm.com/download/win</value>
439439
<value>Chemin d'accès</value>
440440
</data>
441441
<data name="IssuesNavigationItemText" xml:space="preserve">
442-
<value>Questions</value>
442+
<value>Problèmes</value>
443443
</data>
444444
<data name="GraphsNavigationItemText" xml:space="preserve">
445445
<value>Graphes</value>
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>Cloner</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>Ajouter/Changer des comptes</value>
893893
</data>
894894
</root>

src/GitHub.Resources/Resources.it-IT.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>Clona</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>Aggiungi/Modifica account</value>
893893
</data>
894894
</root>

src/GitHub.Resources/Resources.ja-JP.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>複製</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>アカウントの追加または変更</value>
893893
</data>
894894
</root>

src/GitHub.Resources/Resources.ko-KR.resx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ https://git-scm.com/download/win</value>
448448
<value>GitHub에 게시</value>
449449
</data>
450450
<data name="BlurbText" xml:space="preserve">
451-
<value>오픈 소스 및 개인 프로젝트에 대한 강력한 공동 작업, 코드 검토 및 코드 관리.</value>
451+
<value>오픈 소스 및 프라이빗 프로젝트에 대한 강력한 협업, 코드 검토 및 코드 관리.</value>
452452
</data>
453453
<data name="GitHubInvitationSectionConnectLabel" xml:space="preserve">
454454
<value>연결...</value>
@@ -550,7 +550,7 @@ https://git-scm.com/download/win</value>
550550
<value>설명</value>
551551
</data>
552552
<data name="NotAGitHubRepositoryMessage" xml:space="preserve">
553-
<value>이 리포지토리를 GitHub에 게시하고 오픈 소스 및 개인 프로젝트에 대한 강력한 공동 작업, 코드 검토 및 코드 관리를 가져옵니다.</value>
553+
<value>이 리포지토리를 GitHub에 게시하고 오픈 소스 및 프라이빗 프로젝트에 대한 강력한 협업, 코드 검토 및 코드 관리를 가져옵니다.</value>
554554
</data>
555555
<data name="NotAGitHubRepository" xml:space="preserve">
556556
<value>이 리포지토리가 GitHub에 없습니다.</value>
@@ -889,6 +889,6 @@ https://git-scm.com/download/win</value>
889889
<value>복제</value>
890890
</data>
891891
<data name="AddChangeAccounts" xml:space="preserve">
892-
<value>Add/Change Accounts</value>
892+
<value>계정 추가/변경</value>
893893
</data>
894894
</root>

0 commit comments

Comments
 (0)