Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth/PM-15155 - 2FA Component Renames #12092

Merged
merged 8 commits into from
Nov 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { DialogService } from "@bitwarden/components";

import { TwoFactorDuoComponent } from "../../../auth/settings/two-factor-duo.component";
import { TwoFactorSetupComponent as BaseTwoFactorSetupComponent } from "../../../auth/settings/two-factor-setup.component";
import { TwoFactorVerifyComponent } from "../../../auth/settings/two-factor-verify.component";
import { TwoFactorSetupDuoComponent } from "../../../auth/settings/two-factor/two-factor-setup-duo.component";
import { TwoFactorSetupComponent as BaseTwoFactorSetupComponent } from "../../../auth/settings/two-factor/two-factor-setup.component";
import { TwoFactorVerifyComponent } from "../../../auth/settings/two-factor/two-factor-verify.component";

Check warning on line 20 in apps/web/src/app/admin-console/organizations/settings/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/admin-console/organizations/settings/two-factor-setup.component.ts#L18-L20

Added lines #L18 - L20 were not covered by tests

@Component({
selector: "app-two-factor-setup",
templateUrl: "../../../auth/settings/two-factor-setup.component.html",
templateUrl: "../../../auth/settings/two-factor/two-factor-setup.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent implements OnInit {
Expand Down Expand Up @@ -79,12 +79,15 @@
if (!result) {
return;
}
const duoComp: DialogRef<boolean, any> = TwoFactorDuoComponent.open(this.dialogService, {
data: {
authResponse: result,
organizationId: this.organizationId,
const duoComp: DialogRef<boolean, any> = TwoFactorSetupDuoComponent.open(

Check warning on line 82 in apps/web/src/app/admin-console/organizations/settings/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/admin-console/organizations/settings/two-factor-setup.component.ts#L82

Added line #L82 was not covered by tests
this.dialogService,
{
data: {
authResponse: result,
organizationId: this.organizationId,
},
},
});
);
this.twoFactorSetupSubscription = duoComp.componentInstance.onChangeStatus
.pipe(first(), takeUntil(this.destroy$))
.subscribe((enabled: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { RouterModule, Routes } from "@angular/router";

import { ChangePasswordComponent } from "../change-password.component";
import { TwoFactorSetupComponent } from "../two-factor-setup.component";
import { TwoFactorSetupComponent } from "../two-factor/two-factor-setup.component";

Check warning on line 5 in apps/web/src/app/auth/settings/security/security-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/security/security-routing.module.ts#L5

Added line #L5 was not covered by tests

import { SecurityKeysComponent } from "./security-keys.component";
import { SecurityComponent } from "./security.component";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { DialogService, ToastService } from "@bitwarden/components";

import { TwoFactorBaseComponent } from "./two-factor-base.component";
import { TwoFactorSetupMethodBaseComponent } from "./two-factor-setup-method-base.component";

// NOTE: There are additional options available but these are just the ones we are current using.
// See: https://github.com/neocotic/qrious#examples
Expand All @@ -35,11 +35,11 @@
}

@Component({
selector: "app-two-factor-authenticator",
templateUrl: "two-factor-authenticator.component.html",
selector: "app-two-factor-setup-authenticator",
templateUrl: "two-factor-setup-authenticator.component.html",
})
export class TwoFactorAuthenticatorComponent
extends TwoFactorBaseComponent
export class TwoFactorSetupAuthenticatorComponent
extends TwoFactorSetupMethodBaseComponent
implements OnInit, OnDestroy
{
@Output() onChangeStatus = new EventEmitter<boolean>();
Expand Down Expand Up @@ -200,7 +200,7 @@
dialogService: DialogService,
config: DialogConfig<AuthResponse<TwoFactorAuthenticatorResponse>>,
) {
return dialogService.open<boolean>(TwoFactorAuthenticatorComponent, config);
return dialogService.open<boolean>(TwoFactorSetupAuthenticatorComponent, config);

Check warning on line 203 in apps/web/src/app/auth/settings/two-factor/two-factor-setup-authenticator.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup-authenticator.component.ts#L203

Added line #L203 was not covered by tests
}

async launchExternalUrl(url: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService, ToastService } from "@bitwarden/components";

import { TwoFactorBaseComponent } from "./two-factor-base.component";
import { TwoFactorSetupMethodBaseComponent } from "./two-factor-setup-method-base.component";

@Component({
selector: "app-two-factor-duo",
templateUrl: "two-factor-duo.component.html",
selector: "app-two-factor-setup-duo",
templateUrl: "two-factor-setup-duo.component.html",
})
export class TwoFactorDuoComponent extends TwoFactorBaseComponent implements OnInit {
export class TwoFactorSetupDuoComponent
extends TwoFactorSetupMethodBaseComponent
implements OnInit
{
@Output() onChangeStatus: EventEmitter<boolean> = new EventEmitter();

type = TwoFactorProviderType.Duo;
Expand Down Expand Up @@ -137,7 +140,7 @@
dialogService: DialogService,
config: DialogConfig<TwoFactorDuoComponentConfig>,
) => {
return dialogService.open<boolean>(TwoFactorDuoComponent, config);
return dialogService.open<boolean>(TwoFactorSetupDuoComponent, config);

Check warning on line 143 in apps/web/src/app/auth/settings/two-factor/two-factor-setup-duo.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup-duo.component.ts#L143

Added line #L143 was not covered by tests
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService, ToastService } from "@bitwarden/components";

import { TwoFactorBaseComponent } from "./two-factor-base.component";
import { TwoFactorSetupMethodBaseComponent } from "./two-factor-setup-method-base.component";

@Component({
selector: "app-two-factor-email",
templateUrl: "two-factor-email.component.html",
selector: "app-two-factor-setup-email",
templateUrl: "two-factor-setup-email.component.html",
outputs: ["onUpdated"],
})
export class TwoFactorEmailComponent extends TwoFactorBaseComponent implements OnInit {
export class TwoFactorSetupEmailComponent
extends TwoFactorSetupMethodBaseComponent
implements OnInit
{
@Output() onChangeStatus: EventEmitter<boolean> = new EventEmitter();
type = TwoFactorProviderType.Email;
sentEmail: string;
Expand Down Expand Up @@ -139,6 +142,6 @@
dialogService: DialogService,
config: DialogConfig<AuthResponse<TwoFactorEmailResponse>>,
) {
return dialogService.open<boolean>(TwoFactorEmailComponent, config);
return dialogService.open<boolean>(TwoFactorSetupEmailComponent, config);

Check warning on line 145 in apps/web/src/app/auth/settings/two-factor/two-factor-setup-email.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup-email.component.ts#L145

Added line #L145 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService, ToastService } from "@bitwarden/components";

/**
* Base class for two-factor setup components (ex: email, yubikey, webauthn, duo).
*/
@Directive()
export abstract class TwoFactorBaseComponent {
export abstract class TwoFactorSetupMethodBaseComponent {
@Output() onUpdated = new EventEmitter<boolean>();

type: TwoFactorProviderType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService, ToastService } from "@bitwarden/components";

import { TwoFactorBaseComponent } from "./two-factor-base.component";
import { TwoFactorSetupMethodBaseComponent } from "./two-factor-setup-method-base.component";

interface Key {
id: number;
Expand All @@ -29,10 +29,10 @@
}

@Component({
selector: "app-two-factor-webauthn",
templateUrl: "two-factor-webauthn.component.html",
selector: "app-two-factor-setup-webauthn",
templateUrl: "two-factor-setup-webauthn.component.html",
})
export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
export class TwoFactorSetupWebAuthnComponent extends TwoFactorSetupMethodBaseComponent {
type = TwoFactorProviderType.WebAuthn;
name: string;
keys: Key[];
Expand Down Expand Up @@ -213,6 +213,6 @@
dialogService: DialogService,
config: DialogConfig<AuthResponse<TwoFactorWebAuthnResponse>>,
) {
return dialogService.open<boolean>(TwoFactorWebAuthnComponent, config);
return dialogService.open<boolean>(TwoFactorSetupWebAuthnComponent, config);

Check warning on line 216 in apps/web/src/app/auth/settings/two-factor/two-factor-setup-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup-webauthn.component.ts#L216

Added line #L216 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService, ToastService } from "@bitwarden/components";

import { TwoFactorBaseComponent } from "./two-factor-base.component";
import { TwoFactorSetupMethodBaseComponent } from "./two-factor-setup-method-base.component";

interface Key {
key: string;
existingKey: string;
}

@Component({
selector: "app-two-factor-yubikey",
templateUrl: "two-factor-yubikey.component.html",
selector: "app-two-factor-setup-yubikey",
templateUrl: "two-factor-setup-yubikey.component.html",
})
export class TwoFactorYubiKeyComponent extends TwoFactorBaseComponent implements OnInit {
export class TwoFactorSetupYubiKeyComponent
extends TwoFactorSetupMethodBaseComponent
implements OnInit
{
type = TwoFactorProviderType.Yubikey;
keys: Key[];
anyKeyHasNfc = false;
Expand Down Expand Up @@ -169,6 +172,6 @@
dialogService: DialogService,
config: DialogConfig<AuthResponse<TwoFactorYubiKeyResponse>>,
) {
return dialogService.open<boolean>(TwoFactorYubiKeyComponent, config);
return dialogService.open<boolean>(TwoFactorSetupYubiKeyComponent, config);

Check warning on line 175 in apps/web/src/app/auth/settings/two-factor/two-factor-setup-yubikey.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup-yubikey.component.ts#L175

Added line #L175 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { DialogService } from "@bitwarden/components";

import { TwoFactorAuthenticatorComponent } from "./two-factor-authenticator.component";
import { TwoFactorDuoComponent } from "./two-factor-duo.component";
import { TwoFactorEmailComponent } from "./two-factor-email.component";
import { TwoFactorRecoveryComponent } from "./two-factor-recovery.component";
import { TwoFactorSetupAuthenticatorComponent } from "./two-factor-setup-authenticator.component";
import { TwoFactorSetupDuoComponent } from "./two-factor-setup-duo.component";
import { TwoFactorSetupEmailComponent } from "./two-factor-setup-email.component";
import { TwoFactorSetupWebAuthnComponent } from "./two-factor-setup-webauthn.component";
import { TwoFactorSetupYubiKeyComponent } from "./two-factor-setup-yubikey.component";
import { TwoFactorVerifyComponent } from "./two-factor-verify.component";
import { TwoFactorWebAuthnComponent } from "./two-factor-webauthn.component";
import { TwoFactorYubiKeyComponent } from "./two-factor-yubikey.component";

@Component({
selector: "app-two-factor-setup",
Expand Down Expand Up @@ -142,7 +142,7 @@
if (!result) {
return;
}
const authComp: DialogRef<boolean, any> = TwoFactorAuthenticatorComponent.open(
const authComp: DialogRef<boolean, any> = TwoFactorSetupAuthenticatorComponent.open(

Check warning on line 145 in apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts#L145

Added line #L145 was not covered by tests
this.dialogService,
{ data: result },
);
Expand All @@ -160,7 +160,7 @@
if (!result) {
return;
}
const yubiComp: DialogRef<boolean, any> = TwoFactorYubiKeyComponent.open(
const yubiComp: DialogRef<boolean, any> = TwoFactorSetupYubiKeyComponent.open(

Check warning on line 163 in apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts#L163

Added line #L163 was not covered by tests
this.dialogService,
{ data: result },
);
Expand All @@ -177,11 +177,14 @@
if (!result) {
return;
}
const duoComp: DialogRef<boolean, any> = TwoFactorDuoComponent.open(this.dialogService, {
data: {
authResponse: result,
const duoComp: DialogRef<boolean, any> = TwoFactorSetupDuoComponent.open(

Check warning on line 180 in apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts#L180

Added line #L180 was not covered by tests
this.dialogService,
{
data: {
authResponse: result,
},
},
});
);
this.twoFactorSetupSubscription = duoComp.componentInstance.onChangeStatus
.pipe(first(), takeUntil(this.destroy$))
.subscribe((enabled: boolean) => {
Expand All @@ -196,7 +199,7 @@
if (!result) {
return;
}
const emailComp: DialogRef<boolean, any> = TwoFactorEmailComponent.open(
const emailComp: DialogRef<boolean, any> = TwoFactorSetupEmailComponent.open(

Check warning on line 202 in apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts#L202

Added line #L202 was not covered by tests
this.dialogService,
{
data: result,
Expand All @@ -216,7 +219,7 @@
if (!result) {
return;
}
const webAuthnComp: DialogRef<boolean, any> = TwoFactorWebAuthnComponent.open(
const webAuthnComp: DialogRef<boolean, any> = TwoFactorSetupWebAuthnComponent.open(

Check warning on line 222 in apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts#L222

Added line #L222 was not covered by tests
this.dialogService,
{ data: result },
);
Expand Down
36 changes: 18 additions & 18 deletions apps/web/src/app/shared/loose-components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ import { ApiKeyComponent } from "../auth/settings/security/api-key.component";
import { ChangeKdfModule } from "../auth/settings/security/change-kdf/change-kdf.module";
import { SecurityKeysComponent } from "../auth/settings/security/security-keys.component";
import { SecurityComponent } from "../auth/settings/security/security.component";
import { TwoFactorAuthenticatorComponent } from "../auth/settings/two-factor-authenticator.component";
import { TwoFactorDuoComponent } from "../auth/settings/two-factor-duo.component";
import { TwoFactorEmailComponent } from "../auth/settings/two-factor-email.component";
import { TwoFactorRecoveryComponent } from "../auth/settings/two-factor-recovery.component";
import { TwoFactorSetupComponent } from "../auth/settings/two-factor-setup.component";
import { TwoFactorVerifyComponent } from "../auth/settings/two-factor-verify.component";
import { TwoFactorWebAuthnComponent } from "../auth/settings/two-factor-webauthn.component";
import { TwoFactorYubiKeyComponent } from "../auth/settings/two-factor-yubikey.component";
import { TwoFactorRecoveryComponent } from "../auth/settings/two-factor/two-factor-recovery.component";
import { TwoFactorSetupAuthenticatorComponent } from "../auth/settings/two-factor/two-factor-setup-authenticator.component";
import { TwoFactorSetupDuoComponent } from "../auth/settings/two-factor/two-factor-setup-duo.component";
import { TwoFactorSetupEmailComponent } from "../auth/settings/two-factor/two-factor-setup-email.component";
import { TwoFactorSetupWebAuthnComponent } from "../auth/settings/two-factor/two-factor-setup-webauthn.component";
import { TwoFactorSetupYubiKeyComponent } from "../auth/settings/two-factor/two-factor-setup-yubikey.component";
import { TwoFactorSetupComponent } from "../auth/settings/two-factor/two-factor-setup.component";
import { TwoFactorVerifyComponent } from "../auth/settings/two-factor/two-factor-verify.component";
import { UserVerificationModule } from "../auth/shared/components/user-verification";
import { SsoComponent } from "../auth/sso.component";
import { TwoFactorOptionsComponent } from "../auth/two-factor-options.component";
Expand Down Expand Up @@ -159,16 +159,16 @@ import { SharedModule } from "./shared.module";
SponsoredFamiliesComponent,
SponsoringOrgRowComponent,
SsoComponent,
TwoFactorAuthenticatorComponent,
TwoFactorSetupAuthenticatorComponent,
TwoFactorComponent,
TwoFactorDuoComponent,
TwoFactorEmailComponent,
TwoFactorSetupDuoComponent,
TwoFactorSetupEmailComponent,
TwoFactorOptionsComponent,
TwoFactorRecoveryComponent,
TwoFactorSetupComponent,
TwoFactorVerifyComponent,
TwoFactorWebAuthnComponent,
TwoFactorYubiKeyComponent,
TwoFactorSetupWebAuthnComponent,
TwoFactorSetupYubiKeyComponent,
UpdatePasswordComponent,
UpdateTempPasswordComponent,
VerifyEmailTokenComponent,
Expand Down Expand Up @@ -226,16 +226,16 @@ import { SharedModule } from "./shared.module";
SponsoredFamiliesComponent,
SponsoringOrgRowComponent,
SsoComponent,
TwoFactorAuthenticatorComponent,
TwoFactorSetupAuthenticatorComponent,
TwoFactorComponent,
TwoFactorDuoComponent,
TwoFactorEmailComponent,
TwoFactorSetupDuoComponent,
TwoFactorSetupEmailComponent,
TwoFactorOptionsComponent,
TwoFactorRecoveryComponent,
TwoFactorSetupComponent,
TwoFactorVerifyComponent,
TwoFactorWebAuthnComponent,
TwoFactorYubiKeyComponent,
TwoFactorSetupWebAuthnComponent,
TwoFactorSetupYubiKeyComponent,
UpdatePasswordComponent,
UpdateTempPasswordComponent,
UserLayoutComponent,
Expand Down
Loading