Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e475eea

Browse files
committed
Use the actual repository url for auth
1 parent 25c9a8c commit e475eea

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/Services/AuthenticationService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class AuthenticationService
1010

1111
private LoginResult loginResultData;
1212

13-
public AuthenticationService(IAppConfiguration appConfiguration, IKeychain keychain)
13+
public AuthenticationService(UriString host, IAppConfiguration appConfiguration, IKeychain keychain)
1414
{
1515
this.appConfiguration = appConfiguration;
16-
client = ApiClient.Create(UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri), keychain, appConfiguration);
16+
client = ApiClient.Create(host, keychain, appConfiguration);
1717
}
1818

1919
public void Login(string username, string password, Action<string> twofaRequired, Action<bool, string> authResult)

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,34 @@ class AuthenticationView : Subview
2626
[NonSerialized] private bool need2fa;
2727
[NonSerialized] private bool busy;
2828
[NonSerialized] private string message;
29+
2930
[NonSerialized] private AuthenticationService authenticationService;
31+
private AuthenticationService AuthenticationService
32+
{
33+
get
34+
{
35+
if (authenticationService == null)
36+
Initialize();
37+
return authenticationService;
38+
}
39+
set
40+
{
41+
authenticationService = value;
42+
}
43+
}
3044

3145
public override void Initialize(IView parent)
3246
{
3347
base.Initialize(parent);
34-
3548
need2fa = busy = false;
36-
authenticationService = new AuthenticationService(EntryPoint.AppManager.AppConfiguration, EntryPoint.Keychain);
49+
}
50+
51+
private void Initialize()
52+
{
53+
var repository = EntryPoint.Environment.Repository;
54+
var host = repository != null ? repository.CloneUrl.ToRepositoryUrl() : UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
55+
host = !String.IsNullOrEmpty(host) ? host : UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
56+
AuthenticationService = new AuthenticationService(host, EntryPoint.AppManager.AppConfiguration, EntryPoint.Keychain);
3757
}
3858

3959
public override void OnShow()
@@ -120,7 +140,7 @@ private void OnGUILogin()
120140
if (GUILayout.Button(loginButton))
121141
{
122142
busy = true;
123-
authenticationService.Login(username, password, DoRequire2fa, DoResult);
143+
AuthenticationService.Login(username, password, DoRequire2fa, DoResult);
124144
}
125145
GUILayout.EndHorizontal();
126146
GUI.enabled = true;
@@ -161,7 +181,7 @@ private void OnGUI2FA()
161181
if (GUILayout.Button(twofaButton))
162182
{
163183
busy = true;
164-
authenticationService.LoginWith2fa(two2fa);
184+
AuthenticationService.LoginWith2fa(two2fa);
165185
}
166186
GUILayout.EndHorizontal();
167187

0 commit comments

Comments
 (0)