@@ -26,14 +26,34 @@ class AuthenticationView : Subview
26
26
[ NonSerialized ] private bool need2fa ;
27
27
[ NonSerialized ] private bool busy ;
28
28
[ NonSerialized ] private string message ;
29
+
29
30
[ 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
+ }
30
44
31
45
public override void Initialize ( IView parent )
32
46
{
33
47
base . Initialize ( parent ) ;
34
-
35
48
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 ) ;
37
57
}
38
58
39
59
public override void OnShow ( )
@@ -120,7 +140,7 @@ private void OnGUILogin()
120
140
if ( GUILayout . Button ( loginButton ) )
121
141
{
122
142
busy = true ;
123
- authenticationService . Login ( username , password , DoRequire2fa , DoResult ) ;
143
+ AuthenticationService . Login ( username , password , DoRequire2fa , DoResult ) ;
124
144
}
125
145
GUILayout . EndHorizontal ( ) ;
126
146
GUI . enabled = true ;
@@ -161,7 +181,7 @@ private void OnGUI2FA()
161
181
if ( GUILayout . Button ( twofaButton ) )
162
182
{
163
183
busy = true ;
164
- authenticationService . LoginWith2fa ( two2fa ) ;
184
+ AuthenticationService . LoginWith2fa ( two2fa ) ;
165
185
}
166
186
GUILayout . EndHorizontal ( ) ;
167
187
0 commit comments