From bdd6f9f6dfde90750046718647e644020d3c7116 Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:45:55 -0700 Subject: [PATCH] handle browser routing and basic browser template --- apps/browser/src/_locales/en/messages.json | 3 ++ apps/browser/src/popup/app-routing.module.ts | 36 +++++++++++++++---- .../functions/unauth-ui-refresh-route-swap.ts | 2 ++ .../src/angular/login/login.component.html | 23 +++++++++++- .../auth/src/angular/login/login.component.ts | 5 ++- libs/common/src/enums/feature-flag.enum.ts | 2 +- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 32215013ac..e19d5cdd6b 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -756,6 +756,9 @@ "logIn": { "message": "Log in" }, + "logInToBitwarden": { + "message": "Log in to Bitwarden" + }, "restartRegistration": { "message": "Restart registration" }, diff --git a/apps/browser/src/popup/app-routing.module.ts b/apps/browser/src/popup/app-routing.module.ts index 7af8831684..e5761b6c83 100644 --- a/apps/browser/src/popup/app-routing.module.ts +++ b/apps/browser/src/popup/app-routing.module.ts @@ -1,6 +1,8 @@ import { Injectable, NgModule } from "@angular/core"; import { ActivatedRouteSnapshot, RouteReuseStrategy, RouterModule, Routes } from "@angular/router"; +import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component"; +import { unauthUiRefreshSwap } from "@bitwarden/angular/auth/functions/unauth-ui-refresh-route-swap"; import { authGuard, lockGuard, @@ -14,6 +16,7 @@ import { extensionRefreshSwap } from "@bitwarden/angular/utils/extension-refresh import { AnonLayoutWrapperComponent, AnonLayoutWrapperData, + LoginComponentV2, RegistrationFinishComponent, RegistrationStartComponent, RegistrationStartSecondaryComponent, @@ -26,6 +29,7 @@ import { twofactorRefactorSwap } from "../../../../libs/angular/src/utils/two-fa import { fido2AuthGuard } from "../auth/guards/fido2-auth.guard"; import { AccountSwitcherComponent } from "../auth/popup/account-switching/account-switcher.component"; import { EnvironmentComponent } from "../auth/popup/environment.component"; +import { ExtensionAnonLayoutWrapperComponent } from "../auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component"; import { HintComponent } from "../auth/popup/hint.component"; import { HomeComponent } from "../auth/popup/home.component"; import { LockComponent } from "../auth/popup/lock.component"; @@ -134,12 +138,6 @@ const routes: Routes = [ canActivate: [fido2AuthGuard], data: { state: "fido2" }, }), - { - path: "login", - component: LoginComponent, - canActivate: [unauthGuardFn(unauthRouteOverrides)], - data: { state: "login" }, - }, { path: "login-with-device", component: LoginViaAuthRequestComponent, @@ -385,6 +383,32 @@ const routes: Routes = [ canActivate: [authGuard], data: { state: "update-temp-password" }, }, + ...unauthUiRefreshSwap( + LoginComponent, + ExtensionAnonLayoutWrapperComponent, + { + path: "login", + canActivate: [unauthGuardFn(unauthRouteOverrides)], + data: { state: "login" }, + }, + { + path: "", + children: [ + { + path: "login", + canActivate: [unauthGuardFn(unauthRouteOverrides)], + data: { + pageTitle: "logInToBitwarden", + state: "login", + }, // TODO-rr-bw: add `satisfies DataProperties & ExtensionAnonLayoutWrapperData + children: [ + { path: "", component: LoginComponentV2 }, + { path: "", component: EnvironmentSelectorComponent, outlet: "environment-selector" }, + ], + }, + ], + }, + ), { path: "", component: AnonLayoutWrapperComponent, diff --git a/libs/angular/src/auth/functions/unauth-ui-refresh-route-swap.ts b/libs/angular/src/auth/functions/unauth-ui-refresh-route-swap.ts index 45dad4a1a7..1146b7b40e 100644 --- a/libs/angular/src/auth/functions/unauth-ui-refresh-route-swap.ts +++ b/libs/angular/src/auth/functions/unauth-ui-refresh-route-swap.ts @@ -20,6 +20,7 @@ export function unauthUiRefreshSwap( defaultComponent: Type, refreshedComponent: Type, options: Route, + altOptions?: Route, ): Routes { return componentRouteSwap( defaultComponent, @@ -29,5 +30,6 @@ export function unauthUiRefreshSwap( return configService.getFeatureFlag(FeatureFlag.UnauthenticatedExtensionUIRefresh); }, options, + altOptions, ); } diff --git a/libs/auth/src/angular/login/login.component.html b/libs/auth/src/angular/login/login.component.html index e333fbd292..b1b60e24da 100644 --- a/libs/auth/src/angular/login/login.component.html +++ b/libs/auth/src/angular/login/login.component.html @@ -1,4 +1,20 @@ -
+ + + + @@ -141,3 +157,8 @@
+ + +
+
+
diff --git a/libs/auth/src/angular/login/login.component.ts b/libs/auth/src/angular/login/login.component.ts index 9f57e3cfca..30ae80e079 100644 --- a/libs/auth/src/angular/login/login.component.ts +++ b/libs/auth/src/angular/login/login.component.ts @@ -62,6 +62,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy { captcha: CaptchaIFrame; captchaToken: string = null; clientType: ClientType; + ClientType = ClientType; registerRoute$ = this.registerRouteService.registerRoute$(); // TODO: remove when email verification flag is removed showLoginWithDevice = false; validatedEmail = false; @@ -140,7 +141,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy { this.destroy$.complete(); } - submit = async (showToast: boolean): Promise => { + submit = async (showToast = true): Promise => { const data = this.formGroup.value; await this.setupCaptcha(); @@ -153,6 +154,8 @@ export class LoginComponentV2 implements OnInit, OnDestroy { } // Web specific (end) + // TODO-rr-bw: handle toast here for Browser/Desktop? See base LoginComponent -> submit() + const credentials = new PasswordLoginCredentials( data.email, data.masterPassword, diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index 53baea14c5..221c2f469a 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -74,7 +74,7 @@ export const DefaultFeatureFlagValue = { [FeatureFlag.IdpAutoSubmitLogin]: FALSE, [FeatureFlag.DeviceTrustLogging]: FALSE, [FeatureFlag.AuthenticatorTwoFactorToken]: FALSE, - [FeatureFlag.UnauthenticatedExtensionUIRefresh]: FALSE, + [FeatureFlag.UnauthenticatedExtensionUIRefresh]: true, [FeatureFlag.EnableUpgradePasswordManagerSub]: FALSE, [FeatureFlag.GenerateIdentityFillScriptRefactor]: FALSE, [FeatureFlag.EnableNewCardCombinedExpiryAutofill]: FALSE,