From 05e60d8b741780d0652edaf4b3de0d9adfef86e0 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Tue, 21 Dec 2021 14:13:24 +1000 Subject: [PATCH] Properly handle twoFactor --- node/src/cli/commands/login.command.ts | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/node/src/cli/commands/login.command.ts b/node/src/cli/commands/login.command.ts index 7f7b97ca..4f65aee5 100644 --- a/node/src/cli/commands/login.command.ts +++ b/node/src/cli/commands/login.command.ts @@ -150,6 +150,14 @@ export class LoginCommand { return Response.error("Invalid two-step login method."); } + const twoFactor = twoFactorToken == null + ? null + : { + provider: twoFactorMethod, + token: twoFactorToken, + remember: false, + } + try { if (this.validatedParams != null) { await this.validatedParams(); @@ -157,29 +165,17 @@ export class LoginCommand { let response: AuthResult = null; if (clientId != null && clientSecret != null) { - response = await this.authService.logInApiKey(clientId, clientSecret, { - provider: twoFactorMethod, - token: twoFactorToken, - remember: false, - }); + response = await this.authService.logInApiKey(clientId, clientSecret, twoFactor); } else if (ssoCode != null && ssoCodeVerifier != null) { response = await this.authService.logInSso( ssoCode, ssoCodeVerifier, this.ssoRedirectUri, orgIdentifier, - { - provider: twoFactorMethod, - token: twoFactorToken, - remember: false, - } + twoFactor, ); } else { - response = await this.authService.logIn(email, password, { - provider: twoFactorMethod, - token: twoFactorToken, - remember: false, - }); + response = await this.authService.logIn(email, password, twoFactor); } if (response.captchaSiteKey) { const badCaptcha = Response.badRequest(