1
0
mirror of https://github.com/bitwarden/jslib synced 2026-01-19 17:03:16 +00:00

Properly handle twoFactor

This commit is contained in:
Thomas Rittson
2021-12-21 14:13:24 +10:00
parent edc3cb7ee2
commit 05e60d8b74

View File

@@ -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(