@@ -30,8 +30,8 @@ class LoginManager : ILoginManager
30
30
private readonly string fingerprint ;
31
31
private readonly IProcessManager processManager ;
32
32
private readonly ITaskManager taskManager ;
33
- private readonly NPath nodeJsExecutablePath ;
34
- private readonly NPath octorunScript ;
33
+ private readonly NPath ? nodeJsExecutablePath ;
34
+ private readonly NPath ? octorunScript ;
35
35
36
36
/// <summary>
37
37
/// Initializes a new instance of the <see cref="LoginManager"/> class.
@@ -51,7 +51,7 @@ public LoginManager(
51
51
string clientSecret ,
52
52
string authorizationNote = null ,
53
53
string fingerprint = null ,
54
- IProcessManager processManager = null , ITaskManager taskManager = null , NPath nodeJsExecutablePath = null , NPath octorunScript = null )
54
+ IProcessManager processManager = null , ITaskManager taskManager = null , NPath ? nodeJsExecutablePath = null , NPath ? octorunScript = null )
55
55
{
56
56
Guard . ArgumentNotNull ( keychain , nameof ( keychain ) ) ;
57
57
Guard . ArgumentNotNullOrWhiteSpace ( clientId , nameof ( clientId ) ) ;
@@ -251,10 +251,20 @@ private async Task<ApplicationAuthorization> TryLogin(
251
251
string password
252
252
)
253
253
{
254
+ if ( ! nodeJsExecutablePath . HasValue )
255
+ {
256
+ throw new InvalidOperationException ( "nodeJsExecutablePath must be set" ) ;
257
+ }
258
+
259
+ if ( ! octorunScript . HasValue )
260
+ {
261
+ throw new InvalidOperationException ( "octorunScript must be set" ) ;
262
+ }
263
+
254
264
ApplicationAuthorization auth ;
255
- var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath , octorunScript ,
265
+ var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath . Value , octorunScript . Value ,
256
266
"login" , ApplicationInfo . ClientId , ApplicationInfo . ClientSecret ) ;
257
- loginTask . Configure ( processManager , workingDirectory : octorunScript . Parent . Parent , withInput : true ) ;
267
+ loginTask . Configure ( processManager , workingDirectory : octorunScript . Value . Parent . Parent , withInput : true ) ;
258
268
loginTask . OnStartProcess += proc =>
259
269
{
260
270
proc . StandardInput . WriteLine ( username ) ;
@@ -297,12 +307,20 @@ private async Task<ApplicationAuthorization> TryContinueLogin(
297
307
string code
298
308
)
299
309
{
300
- logger . Info ( "Continue Username:{0} {1} {2}" , username , password , code ) ;
310
+ if ( ! nodeJsExecutablePath . HasValue )
311
+ {
312
+ throw new InvalidOperationException ( "nodeJsExecutablePath must be set" ) ;
313
+ }
314
+
315
+ if ( ! octorunScript . HasValue )
316
+ {
317
+ throw new InvalidOperationException ( "octorunScript must be set" ) ;
318
+ }
301
319
302
320
ApplicationAuthorization auth ;
303
- var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath , octorunScript ,
321
+ var loginTask = new OctorunTask ( taskManager . Token , nodeJsExecutablePath . Value , octorunScript . Value ,
304
322
"login --twoFactor" , ApplicationInfo . ClientId , ApplicationInfo . ClientSecret ) ;
305
- loginTask . Configure ( processManager , workingDirectory : octorunScript . Parent . Parent , withInput : true ) ;
323
+ loginTask . Configure ( processManager , workingDirectory : octorunScript . Value . Parent . Parent , withInput : true ) ;
306
324
loginTask . OnStartProcess += proc =>
307
325
{
308
326
proc . StandardInput . WriteLine ( username ) ;
@@ -313,8 +331,6 @@ string code
313
331
314
332
var ret = ( await loginTask . StartAwait ( ) ) ;
315
333
316
- logger . Trace ( "Return: {0}" , string . Join ( ";" , ret . ToArray ( ) ) ) ;
317
-
318
334
if ( ret . Count == 0 )
319
335
{
320
336
throw new Exception ( "Authentication failed" ) ;
0 commit comments