mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
feat(AuthRouteConstants): [Auth/PM-27370] Convert auth routes to use constants (#16980)
* PM-22663 WIP on auth route constants * PM-22663 - Convert desktop & extension to use constants - first pass * PM-22663 - Further clean up * PM-22663 - catch more missed routes * PM-22663 - add barrel files * PM-22663 - Per PR feedback, add missing as const * PM-22663 - Per PR feedback and TS docs, use same name for const enum like and derived type. Adjusted filenames to be singular. * PM-22663 - Per PR feedback update desktop app routing module since auto rename didn't update it for whatever reason.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// Full routes that auth owns in the extension
|
||||
export const AuthExtensionRoute = Object.freeze({
|
||||
AccountSecurity: "account-security",
|
||||
DeviceManagement: "device-management",
|
||||
AccountSwitcher: "account-switcher",
|
||||
} as const);
|
||||
|
||||
export type AuthExtensionRoute = (typeof AuthExtensionRoute)[keyof typeof AuthExtensionRoute];
|
||||
1
apps/browser/src/auth/popup/constants/index.ts
Normal file
1
apps/browser/src/auth/popup/constants/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./auth-extension-route.constant";
|
||||
@@ -2,6 +2,7 @@ import { Injectable, NgModule } from "@angular/core";
|
||||
import { ActivatedRouteSnapshot, RouteReuseStrategy, RouterModule, Routes } from "@angular/router";
|
||||
|
||||
import { AuthenticationTimeoutComponent } from "@bitwarden/angular/auth/components/authentication-timeout.component";
|
||||
import { AuthRoute } from "@bitwarden/angular/auth/constants";
|
||||
import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/environment-selector/environment-selector.component";
|
||||
import {
|
||||
activeAuthGuard,
|
||||
@@ -45,6 +46,7 @@ import { AnonLayoutWrapperComponent, AnonLayoutWrapperData } from "@bitwarden/co
|
||||
import { LockComponent, ConfirmKeyConnectorDomainComponent } from "@bitwarden/key-management-ui";
|
||||
|
||||
import { AccountSwitcherComponent } from "../auth/popup/account-switching/account-switcher.component";
|
||||
import { AuthExtensionRoute } from "../auth/popup/constants/auth-extension-route.constant";
|
||||
import { fido2AuthGuard } from "../auth/popup/guards/fido2-auth.guard";
|
||||
import { AccountSecurityComponent } from "../auth/popup/settings/account-security.component";
|
||||
import { ExtensionDeviceManagementComponent } from "../auth/popup/settings/extension-device-management.component";
|
||||
@@ -148,7 +150,7 @@ const routes: Routes = [
|
||||
component: ExtensionAnonLayoutWrapperComponent,
|
||||
children: [
|
||||
{
|
||||
path: "authentication-timeout",
|
||||
path: AuthRoute.AuthenticationTimeout,
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
children: [
|
||||
{
|
||||
@@ -167,7 +169,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "device-verification",
|
||||
path: AuthRoute.NewDeviceVerification,
|
||||
component: ExtensionAnonLayoutWrapperComponent,
|
||||
canActivate: [unauthGuardFn(), activeAuthGuard()],
|
||||
children: [{ path: "", component: NewDeviceVerificationComponent }],
|
||||
@@ -259,13 +261,13 @@ const routes: Routes = [
|
||||
data: { elevation: 1 } satisfies RouteDataProperties,
|
||||
},
|
||||
{
|
||||
path: "account-security",
|
||||
path: AuthExtensionRoute.AccountSecurity,
|
||||
component: AccountSecurityComponent,
|
||||
canActivate: [authGuard],
|
||||
data: { elevation: 1 } satisfies RouteDataProperties,
|
||||
},
|
||||
{
|
||||
path: "device-management",
|
||||
path: AuthExtensionRoute.DeviceManagement,
|
||||
component: ExtensionDeviceManagementComponent,
|
||||
canActivate: [authGuard],
|
||||
data: { elevation: 1 } satisfies RouteDataProperties,
|
||||
@@ -341,7 +343,7 @@ const routes: Routes = [
|
||||
component: ExtensionAnonLayoutWrapperComponent,
|
||||
children: [
|
||||
{
|
||||
path: "signup",
|
||||
path: AuthRoute.SignUp,
|
||||
canActivate: [unauthGuardFn()],
|
||||
data: {
|
||||
elevation: 1,
|
||||
@@ -361,13 +363,13 @@ const routes: Routes = [
|
||||
component: RegistrationStartSecondaryComponent,
|
||||
outlet: "secondary",
|
||||
data: {
|
||||
loginRoute: "/login",
|
||||
loginRoute: `/${AuthRoute.Login}`,
|
||||
} satisfies RegistrationStartSecondaryComponentData,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "finish-signup",
|
||||
path: AuthRoute.FinishSignUp,
|
||||
canActivate: [unauthGuardFn()],
|
||||
data: {
|
||||
pageIcon: LockIcon,
|
||||
@@ -382,7 +384,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "set-initial-password",
|
||||
path: AuthRoute.SetInitialPassword,
|
||||
canActivate: [authGuard],
|
||||
component: SetInitialPasswordComponent,
|
||||
data: {
|
||||
@@ -390,7 +392,7 @@ const routes: Routes = [
|
||||
} satisfies RouteDataProperties,
|
||||
},
|
||||
{
|
||||
path: "login",
|
||||
path: AuthRoute.Login,
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides), IntroCarouselGuard],
|
||||
data: {
|
||||
pageIcon: VaultIcon,
|
||||
@@ -411,7 +413,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "login-with-passkey",
|
||||
path: AuthRoute.LoginWithPasskey,
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: {
|
||||
pageIcon: TwoFactorAuthSecurityKeyIcon,
|
||||
@@ -434,7 +436,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "sso",
|
||||
path: AuthRoute.Sso,
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: {
|
||||
pageIcon: VaultIcon,
|
||||
@@ -456,7 +458,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "login-with-device",
|
||||
path: AuthRoute.LoginWithDevice,
|
||||
canActivate: [redirectToVaultIfUnlockedGuard()],
|
||||
data: {
|
||||
pageIcon: DevicesIcon,
|
||||
@@ -479,7 +481,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "hint",
|
||||
path: AuthRoute.PasswordHint,
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: {
|
||||
pageTitle: {
|
||||
@@ -502,7 +504,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "admin-approval-requested",
|
||||
path: AuthRoute.AdminApprovalRequested,
|
||||
canActivate: [redirectToVaultIfUnlockedGuard()],
|
||||
data: {
|
||||
pageIcon: DevicesIcon,
|
||||
@@ -519,7 +521,7 @@ const routes: Routes = [
|
||||
children: [{ path: "", component: LoginViaAuthRequestComponent }],
|
||||
},
|
||||
{
|
||||
path: "login-initiated",
|
||||
path: AuthRoute.LoginInitiated,
|
||||
canActivate: [tdeDecryptionRequiredGuard()],
|
||||
data: {
|
||||
pageIcon: DevicesIcon,
|
||||
@@ -557,7 +559,7 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "2fa",
|
||||
path: AuthRoute.TwoFactor,
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides), TwoFactorAuthGuard],
|
||||
children: [
|
||||
{
|
||||
@@ -576,7 +578,7 @@ const routes: Routes = [
|
||||
} satisfies RouteDataProperties & ExtensionAnonLayoutWrapperData,
|
||||
},
|
||||
{
|
||||
path: "change-password",
|
||||
path: AuthRoute.ChangePassword,
|
||||
data: {
|
||||
elevation: 1,
|
||||
hideFooter: true,
|
||||
@@ -698,7 +700,7 @@ const routes: Routes = [
|
||||
canActivate: [authGuard, canAccessAtRiskPasswords, hasAtRiskPasswords],
|
||||
},
|
||||
{
|
||||
path: "account-switcher",
|
||||
path: AuthExtensionRoute.AccountSwitcher,
|
||||
component: AccountSwitcherComponent,
|
||||
data: { elevation: 4, doNotSaveUrl: true } satisfies RouteDataProperties,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user