Skip to content

Commit

Permalink
Add feature flag and extra guards to device-verification route
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-livefront committed Jan 22, 2025
1 parent 9fd82e1 commit 1cbb521
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
8 changes: 7 additions & 1 deletion apps/browser/src/popup/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
tdeDecryptionRequiredGuard,
unauthGuardFn,
} from "@bitwarden/angular/auth/guards";
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";

Check warning on line 20 in apps/browser/src/popup/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app-routing.module.ts#L20

Added line #L20 was not covered by tests
import { twofactorRefactorSwap } from "@bitwarden/angular/utils/two-factor-component-refactor-route-swap";
import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards";
import {
Expand All @@ -43,6 +44,7 @@ import {
NewDeviceVerificationComponent,
DeviceVerificationIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";

Check warning on line 47 in apps/browser/src/popup/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app-routing.module.ts#L47

Added line #L47 was not covered by tests
import { LockComponent } from "@bitwarden/key-management/angular";
import {
NewDeviceVerificationNoticePageOneComponent,
Expand Down Expand Up @@ -236,7 +238,11 @@ const routes: Routes = [
{
path: "device-verification",
component: ExtensionAnonLayoutWrapperComponent,
canActivate: [activeAuthGuard()],
canActivate: [
canAccessFeature(FeatureFlag.NewDeviceVerification),
unauthGuardFn(),
activeAuthGuard(),
],
children: [{ path: "", component: NewDeviceVerificationComponent }],
data: {
pageIcon: DeviceVerificationIcon,
Expand Down
8 changes: 7 additions & 1 deletion apps/desktop/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
tdeDecryptionRequiredGuard,
unauthGuardFn,
} from "@bitwarden/angular/auth/guards";
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";

Check warning on line 18 in apps/desktop/src/app/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/app-routing.module.ts#L18

Added line #L18 was not covered by tests
import { twofactorRefactorSwap } from "@bitwarden/angular/utils/two-factor-component-refactor-route-swap";
import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards";
import {
Expand All @@ -41,6 +42,7 @@ import {
NewDeviceVerificationComponent,
DeviceVerificationIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";

Check warning on line 45 in apps/desktop/src/app/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/app-routing.module.ts#L45

Added line #L45 was not covered by tests
import { LockComponent } from "@bitwarden/key-management/angular";
import {
NewDeviceVerificationNoticePageOneComponent,
Expand Down Expand Up @@ -118,7 +120,11 @@ const routes: Routes = [
{
path: "device-verification",
component: AnonLayoutWrapperComponent,
canActivate: [activeAuthGuard()],
canActivate: [
canAccessFeature(FeatureFlag.NewDeviceVerification),
unauthGuardFn(),
activeAuthGuard(),
],
children: [{ path: "", component: NewDeviceVerificationComponent }],
data: {
pageIcon: DeviceVerificationIcon,
Expand Down
8 changes: 7 additions & 1 deletion apps/web/src/app/oss-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
unauthGuardFn,
activeAuthGuard,
} from "@bitwarden/angular/auth/guards";
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";

Check warning on line 14 in apps/web/src/app/oss-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/oss-routing.module.ts#L14

Added line #L14 was not covered by tests
import { generatorSwap } from "@bitwarden/angular/tools/generator/generator-swap";
import { twofactorRefactorSwap } from "@bitwarden/angular/utils/two-factor-component-refactor-route-swap";
import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards";
Expand Down Expand Up @@ -41,6 +42,7 @@ import {
NewDeviceVerificationComponent,
DeviceVerificationIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";

Check warning on line 45 in apps/web/src/app/oss-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/oss-routing.module.ts#L45

Added line #L45 was not covered by tests
import { LockComponent } from "@bitwarden/key-management/angular";
import {
NewDeviceVerificationNoticePageOneComponent,
Expand Down Expand Up @@ -585,7 +587,11 @@ const routes: Routes = [
},
{
path: "device-verification",
canActivate: [activeAuthGuard()],
canActivate: [
canAccessFeature(FeatureFlag.NewDeviceVerification),
unauthGuardFn(),
activeAuthGuard(),
],
children: [
{
path: "",
Expand Down
2 changes: 2 additions & 0 deletions libs/common/src/enums/feature-flag.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export enum FeatureFlag {
PM9111ExtensionPersistAddEditForm = "pm-9111-extension-persist-add-edit-form",
PrivateKeyRegeneration = "pm-12241-private-key-regeneration",
ResellerManagedOrgAlert = "PM-15814-alert-owners-of-reseller-managed-orgs",
NewDeviceVerification = "new-device-verification",
}

export type AllowedFeatureFlagTypes = boolean | number | string;
Expand Down Expand Up @@ -104,6 +105,7 @@ export const DefaultFeatureFlagValue = {
[FeatureFlag.PM9111ExtensionPersistAddEditForm]: FALSE,
[FeatureFlag.PrivateKeyRegeneration]: FALSE,
[FeatureFlag.ResellerManagedOrgAlert]: FALSE,
[FeatureFlag.NewDeviceVerification]: FALSE,
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;

export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
Expand Down

0 comments on commit 1cbb521

Please sign in to comment.