From e9f23cd4c3ef1553d41eb7f02057b3408498ef1b Mon Sep 17 00:00:00 2001 From: Ike <137194738+ike-kottlowski@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:29:25 -0500 Subject: [PATCH] feat(newDeviceVerification) : add handling for requires new device verification auth response (#13568) --- apps/cli/src/auth/commands/login.command.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/cli/src/auth/commands/login.command.ts b/apps/cli/src/auth/commands/login.command.ts index 14cd93f370f..985816fb0dd 100644 --- a/apps/cli/src/auth/commands/login.command.ts +++ b/apps/cli/src/auth/commands/login.command.ts @@ -311,6 +311,26 @@ export class LoginCommand { ); } + // Opting for not checking feature flag since the server will not respond with + // requiresDeviceVerification if the feature flag is not enabled. + if (response.requiresDeviceVerification) { + let newDeviceToken: string = null; + if (this.canInteract) { + const answer: inquirer.Answers = await inquirer.createPromptModule({ + output: process.stderr, + })({ + type: "input", + name: "token", + message: "New device login code:", + }); + newDeviceToken = answer.token; + } + if (newDeviceToken == null || newDeviceToken === "") { + return Response.badRequest("Code is required."); + } + response = await this.loginStrategyService.logInNewDeviceVerification(newDeviceToken); + } + if (response.captchaSiteKey) { const twoFactorRequest = new TokenTwoFactorRequest(selectedProvider.type, twoFactorToken); const handledResponse = await this.handleCaptchaRequired(twoFactorRequest);