@@ -26,8 +26,8 @@ class LoginManager : ILoginManager
26
26
private readonly string clientSecret ;
27
27
private readonly IProcessManager processManager ;
28
28
private readonly ITaskManager taskManager ;
29
- private readonly NPath nodeJsExecutablePath ;
30
- private readonly NPath octorunScript ;
29
+ private readonly NPath ? nodeJsExecutablePath ;
30
+ private readonly NPath ? octorunScript ;
31
31
32
32
/// <summary>
33
33
/// Initializes a new instance of the <see cref="LoginManager"/> class.
@@ -43,7 +43,7 @@ public LoginManager(
43
43
IKeychain keychain ,
44
44
string clientId ,
45
45
string clientSecret ,
46
- IProcessManager processManager = null , ITaskManager taskManager = null , NPath nodeJsExecutablePath = null , NPath octorunScript = null )
46
+ IProcessManager processManager = null , ITaskManager taskManager = null , NPath ? nodeJsExecutablePath = null , NPath ? octorunScript = null )
47
47
{
48
48
Guard . ArgumentNotNull ( keychain , nameof ( keychain ) ) ;
49
49
Guard . ArgumentNotNullOrWhiteSpace ( clientId , nameof ( clientId ) ) ;
@@ -149,9 +149,19 @@ private async Task<string> TryLogin(
149
149
string password
150
150
)
151
151
{
152
- var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath , octorunScript ,
152
+ if ( ! nodeJsExecutablePath . HasValue )
153
+ {
154
+ throw new InvalidOperationException ( "nodeJsExecutablePath must be set" ) ;
155
+ }
156
+
157
+ if ( ! octorunScript . HasValue )
158
+ {
159
+ throw new InvalidOperationException ( "octorunScript must be set" ) ;
160
+ }
161
+
162
+ var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath . Value , octorunScript . Value ,
153
163
"login" , ApplicationInfo . ClientId , ApplicationInfo . ClientSecret ) ;
154
- loginTask . Configure ( processManager , workingDirectory : octorunScript . Parent . Parent , withInput : true ) ;
164
+ loginTask . Configure ( processManager , workingDirectory : octorunScript . Value . Parent . Parent , withInput : true ) ;
155
165
loginTask . OnStartProcess += proc =>
156
166
{
157
167
proc . StandardInput . WriteLine ( username ) ;
@@ -193,11 +203,19 @@ private async Task<string> TryContinueLogin(
193
203
string code
194
204
)
195
205
{
196
- logger . Info ( "Continue Username:{0} {1} {2}" , username , password , code ) ;
206
+ if ( ! nodeJsExecutablePath . HasValue )
207
+ {
208
+ throw new InvalidOperationException ( "nodeJsExecutablePath must be set" ) ;
209
+ }
210
+
211
+ if ( ! octorunScript . HasValue )
212
+ {
213
+ throw new InvalidOperationException ( "octorunScript must be set" ) ;
214
+ }
197
215
198
- var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath , octorunScript ,
216
+ var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath . Value , octorunScript . Value ,
199
217
"login --twoFactor" , ApplicationInfo . ClientId , ApplicationInfo . ClientSecret ) ;
200
- loginTask . Configure ( processManager , workingDirectory : octorunScript . Parent . Parent , withInput : true ) ;
218
+ loginTask . Configure ( processManager , workingDirectory : octorunScript . Value . Parent . Parent , withInput : true ) ;
201
219
loginTask . OnStartProcess += proc =>
202
220
{
203
221
proc . StandardInput . WriteLine ( username ) ;
@@ -208,8 +226,6 @@ string code
208
226
209
227
var ret = ( await loginTask . StartAwait ( ) ) ;
210
228
211
- logger . Trace ( "Return: {0}" , string . Join ( ";" , ret . ToArray ( ) ) ) ;
212
-
213
229
if ( ret . Count == 0 )
214
230
{
215
231
throw new Exception ( "Authentication failed" ) ;
0 commit comments