1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 14:53:33 +00:00

[PM-21600] Migrate account and security to standalone (#14762)

Migrates account and security settings components to standalone and removing them from the `LooseComponentsModule`.
This commit is contained in:
Oscar Hinton
2025-05-27 10:03:54 +02:00
committed by GitHub
parent beb00a206b
commit a6e2012087
13 changed files with 62 additions and 54 deletions

View File

@@ -8,16 +8,27 @@ import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { DialogService } from "@bitwarden/components"; import { DialogService } from "@bitwarden/components";
import { HeaderModule } from "../../../layouts/header/header.module";
import { SharedModule } from "../../../shared";
import { PurgeVaultComponent } from "../../../vault/settings/purge-vault.component"; import { PurgeVaultComponent } from "../../../vault/settings/purge-vault.component";
import { ChangeEmailComponent } from "./change-email.component";
import { DangerZoneComponent } from "./danger-zone.component";
import { DeauthorizeSessionsComponent } from "./deauthorize-sessions.component"; import { DeauthorizeSessionsComponent } from "./deauthorize-sessions.component";
import { DeleteAccountDialogComponent } from "./delete-account-dialog.component"; import { DeleteAccountDialogComponent } from "./delete-account-dialog.component";
import { ProfileComponent } from "./profile.component";
import { SetAccountVerifyDevicesDialogComponent } from "./set-account-verify-devices-dialog.component"; import { SetAccountVerifyDevicesDialogComponent } from "./set-account-verify-devices-dialog.component";
@Component({ @Component({
selector: "app-account",
templateUrl: "account.component.html", templateUrl: "account.component.html",
standalone: false, standalone: true,
imports: [
SharedModule,
HeaderModule,
ProfileComponent,
ChangeEmailComponent,
DangerZoneComponent,
],
}) })
export class AccountComponent implements OnInit, OnDestroy { export class AccountComponent implements OnInit, OnDestroy {
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();

View File

@@ -24,6 +24,10 @@ import {
ToastService, ToastService,
} from "@bitwarden/components"; } from "@bitwarden/components";
import { SharedModule } from "../../../shared";
import { SelectableAvatarComponent } from "./selectable-avatar.component";
type ChangeAvatarDialogData = { type ChangeAvatarDialogData = {
profile: ProfileResponse; profile: ProfileResponse;
}; };
@@ -31,7 +35,8 @@ type ChangeAvatarDialogData = {
@Component({ @Component({
templateUrl: "change-avatar-dialog.component.html", templateUrl: "change-avatar-dialog.component.html",
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
standalone: false, standalone: true,
imports: [SharedModule, SelectableAvatarComponent],
}) })
export class ChangeAvatarDialogComponent implements OnInit, OnDestroy { export class ChangeAvatarDialogComponent implements OnInit, OnDestroy {
profile: ProfileResponse; profile: ProfileResponse;

View File

@@ -33,8 +33,7 @@ describe("ChangeEmailComponent", () => {
accountService = mockAccountServiceWith("UserId" as UserId); accountService = mockAccountServiceWith("UserId" as UserId);
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ChangeEmailComponent], imports: [ReactiveFormsModule, SharedModule, ChangeEmailComponent],
imports: [ReactiveFormsModule, SharedModule],
providers: [ providers: [
{ provide: AccountService, useValue: accountService }, { provide: AccountService, useValue: accountService },
{ provide: ApiService, useValue: apiService }, { provide: ApiService, useValue: apiService },

View File

@@ -14,10 +14,13 @@ import { UserId } from "@bitwarden/common/types/guid";
import { ToastService } from "@bitwarden/components"; import { ToastService } from "@bitwarden/components";
import { KdfConfigService, KeyService } from "@bitwarden/key-management"; import { KdfConfigService, KeyService } from "@bitwarden/key-management";
import { SharedModule } from "../../../shared";
@Component({ @Component({
selector: "app-change-email", selector: "app-change-email",
templateUrl: "change-email.component.html", templateUrl: "change-email.component.html",
standalone: false, standalone: true,
imports: [SharedModule],
}) })
export class ChangeEmailComponent implements OnInit { export class ChangeEmailComponent implements OnInit {
tokenSent = false; tokenSent = false;

View File

@@ -3,8 +3,8 @@
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { Component } from "@angular/core"; import { Component } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { TypographyModule } from "@bitwarden/components"; import { TypographyModule } from "@bitwarden/components";
import { I18nPipe } from "@bitwarden/ui-common";
/** /**
* Component for the Danger Zone section of the Account/Organization Settings page. * Component for the Danger Zone section of the Account/Organization Settings page.
@@ -13,6 +13,6 @@ import { TypographyModule } from "@bitwarden/components";
selector: "app-danger-zone", selector: "app-danger-zone",
templateUrl: "danger-zone.component.html", templateUrl: "danger-zone.component.html",
standalone: true, standalone: true,
imports: [TypographyModule, JslibModule, CommonModule], imports: [CommonModule, TypographyModule, I18nPipe],
}) })
export class DangerZoneComponent {} export class DangerZoneComponent {}

View File

@@ -1,6 +1,7 @@
import { Component } from "@angular/core"; import { Component } from "@angular/core";
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from "@angular/forms";
import { UserVerificationFormInputComponent } from "@bitwarden/auth/angular";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
import { Verification } from "@bitwarden/common/auth/types/verification"; import { Verification } from "@bitwarden/common/auth/types/verification";
@@ -9,10 +10,12 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { DialogService, ToastService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { SharedModule } from "../../../shared";
@Component({ @Component({
selector: "app-deauthorize-sessions",
templateUrl: "deauthorize-sessions.component.html", templateUrl: "deauthorize-sessions.component.html",
standalone: false, standalone: true,
imports: [SharedModule, UserVerificationFormInputComponent],
}) })
export class DeauthorizeSessionsComponent { export class DeauthorizeSessionsComponent {
deauthForm = this.formBuilder.group({ deauthForm = this.formBuilder.group({

View File

@@ -3,15 +3,19 @@
import { Component } from "@angular/core"; import { Component } from "@angular/core";
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from "@angular/forms";
import { UserVerificationFormInputComponent } from "@bitwarden/auth/angular";
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service"; import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
import { Verification } from "@bitwarden/common/auth/types/verification"; import { Verification } from "@bitwarden/common/auth/types/verification";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response"; import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { DialogRef, DialogService, ToastService } from "@bitwarden/components"; import { DialogRef, DialogService, ToastService } from "@bitwarden/components";
import { SharedModule } from "../../../shared";
@Component({ @Component({
templateUrl: "delete-account-dialog.component.html", templateUrl: "delete-account-dialog.component.html",
standalone: false, standalone: true,
imports: [SharedModule, UserVerificationFormInputComponent],
}) })
export class DeleteAccountDialogComponent { export class DeleteAccountDialogComponent {
deleteForm = this.formBuilder.group({ deleteForm = this.formBuilder.group({

View File

@@ -14,12 +14,17 @@ import { ProfileResponse } from "@bitwarden/common/models/response/profile.respo
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { DialogService, ToastService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { DynamicAvatarComponent } from "../../../components/dynamic-avatar.component";
import { SharedModule } from "../../../shared";
import { AccountFingerprintComponent } from "../../../shared/components/account-fingerprint/account-fingerprint.component";
import { ChangeAvatarDialogComponent } from "./change-avatar-dialog.component"; import { ChangeAvatarDialogComponent } from "./change-avatar-dialog.component";
@Component({ @Component({
selector: "app-profile", selector: "app-profile",
templateUrl: "profile.component.html", templateUrl: "profile.component.html",
standalone: false, standalone: true,
imports: [SharedModule, DynamicAvatarComponent, AccountFingerprintComponent],
}) })
export class ProfileComponent implements OnInit, OnDestroy { export class ProfileComponent implements OnInit, OnDestroy {
loading = true; loading = true;

View File

@@ -1,7 +1,10 @@
// FIXME: Update this file to be type safe and remove this and next line // FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore // @ts-strict-ignore
import { NgClass } from "@angular/common";
import { Component, EventEmitter, Input, Output } from "@angular/core"; import { Component, EventEmitter, Input, Output } from "@angular/core";
import { AvatarModule } from "@bitwarden/components";
@Component({ @Component({
selector: "selectable-avatar", selector: "selectable-avatar",
template: `<span template: `<span
@@ -24,7 +27,8 @@ import { Component, EventEmitter, Input, Output } from "@angular/core";
> >
</bit-avatar> </bit-avatar>
</span>`, </span>`,
standalone: false, standalone: true,
imports: [NgClass, AvatarModule],
}) })
export class SelectableAvatarComponent { export class SelectableAvatarComponent {
@Input() id: string; @Input() id: string;

View File

@@ -3,12 +3,15 @@
import { Component, Inject } from "@angular/core"; import { Component, Inject } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms"; import { FormBuilder, Validators } from "@angular/forms";
import { UserVerificationFormInputComponent } from "@bitwarden/auth/angular";
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
import { SecretVerificationRequest } from "@bitwarden/common/auth/models/request/secret-verification.request"; import { SecretVerificationRequest } from "@bitwarden/common/auth/models/request/secret-verification.request";
import { ApiKeyResponse } from "@bitwarden/common/auth/models/response/api-key.response"; import { ApiKeyResponse } from "@bitwarden/common/auth/models/response/api-key.response";
import { Verification } from "@bitwarden/common/auth/types/verification"; import { Verification } from "@bitwarden/common/auth/types/verification";
import { DIALOG_DATA, DialogConfig, DialogService } from "@bitwarden/components"; import { DIALOG_DATA, DialogConfig, DialogService } from "@bitwarden/components";
import { SharedModule } from "../../../shared";
export type ApiKeyDialogData = { export type ApiKeyDialogData = {
keyType: string; keyType: string;
isRotation?: boolean; isRotation?: boolean;
@@ -21,9 +24,9 @@ export type ApiKeyDialogData = {
apiKeyDescription: string; apiKeyDescription: string;
}; };
@Component({ @Component({
selector: "app-api-key",
templateUrl: "api-key.component.html", templateUrl: "api-key.component.html",
standalone: false, standalone: true,
imports: [SharedModule, UserVerificationFormInputComponent],
}) })
export class ApiKeyComponent { export class ApiKeyComponent {
clientId: string; clientId: string;

View File

@@ -8,12 +8,15 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
import { DialogService } from "@bitwarden/components"; import { DialogService } from "@bitwarden/components";
import { SharedModule } from "../../../shared";
import { ApiKeyComponent } from "./api-key.component"; import { ApiKeyComponent } from "./api-key.component";
import { ChangeKdfModule } from "./change-kdf/change-kdf.module";
@Component({ @Component({
selector: "app-security-keys",
templateUrl: "security-keys.component.html", templateUrl: "security-keys.component.html",
standalone: false, standalone: true,
imports: [SharedModule, ChangeKdfModule],
}) })
export class SecurityKeysComponent implements OnInit { export class SecurityKeysComponent implements OnInit {
showChangeKdf = true; showChangeKdf = true;

View File

@@ -4,10 +4,13 @@ import { UserVerificationService } from "@bitwarden/common/auth/abstractions/use
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { HeaderModule } from "../../../layouts/header/header.module";
import { SharedModule } from "../../../shared";
@Component({ @Component({
selector: "app-security",
templateUrl: "security.component.html", templateUrl: "security.component.html",
standalone: false, standalone: true,
imports: [SharedModule, HeaderModule],
}) })
export class SecurityComponent implements OnInit { export class SecurityComponent implements OnInit {
showChangePassword = true; showChangePassword = true;

View File

@@ -15,23 +15,12 @@ import { AcceptFamilySponsorshipComponent } from "../admin-console/organizations
import { RecoverDeleteComponent } from "../auth/recover-delete.component"; import { RecoverDeleteComponent } from "../auth/recover-delete.component";
import { RecoverTwoFactorComponent } from "../auth/recover-two-factor.component"; import { RecoverTwoFactorComponent } from "../auth/recover-two-factor.component";
import { SetPasswordComponent } from "../auth/set-password.component"; import { SetPasswordComponent } from "../auth/set-password.component";
import { AccountComponent } from "../auth/settings/account/account.component";
import { ChangeAvatarDialogComponent } from "../auth/settings/account/change-avatar-dialog.component";
import { ChangeEmailComponent } from "../auth/settings/account/change-email.component";
import { DangerZoneComponent } from "../auth/settings/account/danger-zone.component"; import { DangerZoneComponent } from "../auth/settings/account/danger-zone.component";
import { DeauthorizeSessionsComponent } from "../auth/settings/account/deauthorize-sessions.component";
import { DeleteAccountDialogComponent } from "../auth/settings/account/delete-account-dialog.component";
import { ProfileComponent } from "../auth/settings/account/profile.component";
import { SelectableAvatarComponent } from "../auth/settings/account/selectable-avatar.component";
import { EmergencyAccessConfirmComponent } from "../auth/settings/emergency-access/confirm/emergency-access-confirm.component"; import { EmergencyAccessConfirmComponent } from "../auth/settings/emergency-access/confirm/emergency-access-confirm.component";
import { EmergencyAccessAddEditComponent } from "../auth/settings/emergency-access/emergency-access-add-edit.component"; import { EmergencyAccessAddEditComponent } from "../auth/settings/emergency-access/emergency-access-add-edit.component";
import { EmergencyAccessComponent } from "../auth/settings/emergency-access/emergency-access.component"; import { EmergencyAccessComponent } from "../auth/settings/emergency-access/emergency-access.component";
import { EmergencyAccessTakeoverComponent } from "../auth/settings/emergency-access/takeover/emergency-access-takeover.component"; import { EmergencyAccessTakeoverComponent } from "../auth/settings/emergency-access/takeover/emergency-access-takeover.component";
import { EmergencyAccessViewComponent } from "../auth/settings/emergency-access/view/emergency-access-view.component"; import { EmergencyAccessViewComponent } from "../auth/settings/emergency-access/view/emergency-access-view.component";
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 { UserVerificationModule } from "../auth/shared/components/user-verification"; import { UserVerificationModule } from "../auth/shared/components/user-verification";
import { UpdatePasswordComponent } from "../auth/update-password.component"; import { UpdatePasswordComponent } from "../auth/update-password.component";
import { UpdateTempPasswordComponent } from "../auth/update-temp-password.component"; import { UpdateTempPasswordComponent } from "../auth/update-temp-password.component";
@@ -39,7 +28,6 @@ import { VerifyEmailTokenComponent } from "../auth/verify-email-token.component"
import { VerifyRecoverDeleteComponent } from "../auth/verify-recover-delete.component"; import { VerifyRecoverDeleteComponent } from "../auth/verify-recover-delete.component";
import { SponsoredFamiliesComponent } from "../billing/settings/sponsored-families.component"; import { SponsoredFamiliesComponent } from "../billing/settings/sponsored-families.component";
import { SponsoringOrgRowComponent } from "../billing/settings/sponsoring-org-row.component"; import { SponsoringOrgRowComponent } from "../billing/settings/sponsoring-org-row.component";
import { DynamicAvatarComponent } from "../components/dynamic-avatar.component";
// eslint-disable-next-line no-restricted-imports -- Temporarily disabled until DIRT refactors these out of this module // eslint-disable-next-line no-restricted-imports -- Temporarily disabled until DIRT refactors these out of this module
import { ExposedPasswordsReportComponent as OrgExposedPasswordsReportComponent } from "../dirt/reports/pages/organizations/exposed-passwords-report.component"; import { ExposedPasswordsReportComponent as OrgExposedPasswordsReportComponent } from "../dirt/reports/pages/organizations/exposed-passwords-report.component";
// eslint-disable-next-line no-restricted-imports -- Temporarily disabled until DIRT refactors these out of this module // eslint-disable-next-line no-restricted-imports -- Temporarily disabled until DIRT refactors these out of this module
@@ -68,8 +56,6 @@ import { SharedModule } from "./shared.module";
imports: [ imports: [
SharedModule, SharedModule,
UserVerificationModule, UserVerificationModule,
ChangeKdfModule,
DynamicAvatarComponent,
AccountFingerprintComponent, AccountFingerprintComponent,
OrganizationBadgeModule, OrganizationBadgeModule,
PipesModule, PipesModule,
@@ -85,11 +71,6 @@ import { SharedModule } from "./shared.module";
], ],
declarations: [ declarations: [
AcceptFamilySponsorshipComponent, AcceptFamilySponsorshipComponent,
AccountComponent,
ApiKeyComponent,
ChangeEmailComponent,
DeauthorizeSessionsComponent,
DeleteAccountDialogComponent,
EmergencyAccessAddEditComponent, EmergencyAccessAddEditComponent,
EmergencyAccessComponent, EmergencyAccessComponent,
EmergencyAccessConfirmComponent, EmergencyAccessConfirmComponent,
@@ -104,15 +85,10 @@ import { SharedModule } from "./shared.module";
OrgUserConfirmComponent, OrgUserConfirmComponent,
OrgWeakPasswordsReportComponent, OrgWeakPasswordsReportComponent,
PremiumBadgeComponent, PremiumBadgeComponent,
ProfileComponent,
ChangeAvatarDialogComponent,
PurgeVaultComponent, PurgeVaultComponent,
RecoverDeleteComponent, RecoverDeleteComponent,
RecoverTwoFactorComponent, RecoverTwoFactorComponent,
RemovePasswordComponent, RemovePasswordComponent,
SecurityComponent,
SecurityKeysComponent,
SelectableAvatarComponent,
SetPasswordComponent, SetPasswordComponent,
SponsoredFamiliesComponent, SponsoredFamiliesComponent,
FreeBitwardenFamiliesComponent, FreeBitwardenFamiliesComponent,
@@ -125,12 +101,6 @@ import { SharedModule } from "./shared.module";
exports: [ exports: [
UserVerificationModule, UserVerificationModule,
PremiumBadgeComponent, PremiumBadgeComponent,
AccountComponent,
ApiKeyComponent,
ChangeEmailComponent,
DeauthorizeSessionsComponent,
DeleteAccountDialogComponent,
DynamicAvatarComponent,
EmergencyAccessAddEditComponent, EmergencyAccessAddEditComponent,
EmergencyAccessComponent, EmergencyAccessComponent,
EmergencyAccessConfirmComponent, EmergencyAccessConfirmComponent,
@@ -146,15 +116,10 @@ import { SharedModule } from "./shared.module";
OrgUserConfirmComponent, OrgUserConfirmComponent,
OrgWeakPasswordsReportComponent, OrgWeakPasswordsReportComponent,
PremiumBadgeComponent, PremiumBadgeComponent,
ProfileComponent,
ChangeAvatarDialogComponent,
PurgeVaultComponent, PurgeVaultComponent,
RecoverDeleteComponent, RecoverDeleteComponent,
RecoverTwoFactorComponent, RecoverTwoFactorComponent,
RemovePasswordComponent, RemovePasswordComponent,
SecurityComponent,
SecurityKeysComponent,
SelectableAvatarComponent,
SetPasswordComponent, SetPasswordComponent,
SponsoredFamiliesComponent, SponsoredFamiliesComponent,
FreeBitwardenFamiliesComponent, FreeBitwardenFamiliesComponent,