diff --git a/apps/browser/src/auth/guards/fido2-auth.guard.ts b/apps/browser/src/auth/guards/fido2-auth.guard.ts index 03dd575aaa..a5e08871b6 100644 --- a/apps/browser/src/auth/guards/fido2-auth.guard.ts +++ b/apps/browser/src/auth/guards/fido2-auth.guard.ts @@ -22,12 +22,12 @@ export const fido2AuthGuard: CanActivateFn = async ( const authStatus = await authService.getAuthStatus(); if (authStatus === AuthenticationStatus.LoggedOut) { - await routerService.setPreviousUrl(state.url); + routerService.setPreviousUrl(state.url); return router.createUrlTree(["/home"], { queryParams: route.queryParams }); } if (authStatus === AuthenticationStatus.Locked) { - await routerService.setPreviousUrl(state.url); + routerService.setPreviousUrl(state.url); return router.createUrlTree(["/lock"], { queryParams: route.queryParams }); } diff --git a/apps/browser/src/auth/popup/lock.component.ts b/apps/browser/src/auth/popup/lock.component.ts index dc3341a75d..0e3502dc8e 100644 --- a/apps/browser/src/auth/popup/lock.component.ts +++ b/apps/browser/src/auth/popup/lock.component.ts @@ -80,7 +80,7 @@ export class LockComponent extends BaseLockComponent { this.isInitialLockScreen = (window as any).previousPopupUrl == null; super.onSuccessfulSubmit = async () => { - const previousUrl = await this.routerService.getPreviousUrl(); + const previousUrl = this.routerService.getPreviousUrl(); if (previousUrl) { this.router.navigateByUrl(previousUrl); } else { diff --git a/apps/browser/src/auth/popup/login.component.ts b/apps/browser/src/auth/popup/login.component.ts index 1cca374db8..940343d4a4 100644 --- a/apps/browser/src/auth/popup/login.component.ts +++ b/apps/browser/src/auth/popup/login.component.ts @@ -73,7 +73,7 @@ export class LoginComponent extends BaseLoginComponent { super.successRoute = "/tabs/vault"; super.onSuccessfulLoginNavigate = async () => { - const previousUrl = await this.routerService.getPreviousUrl(); + const previousUrl = this.routerService.getPreviousUrl(); if (previousUrl) { this.router.navigateByUrl(previousUrl); diff --git a/apps/browser/src/auth/popup/two-factor.component.ts b/apps/browser/src/auth/popup/two-factor.component.ts index 13755fe2eb..f4d09aa26e 100644 --- a/apps/browser/src/auth/popup/two-factor.component.ts +++ b/apps/browser/src/auth/popup/two-factor.component.ts @@ -87,7 +87,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent { super.successRoute = "/tabs/vault"; super.onSuccessfulLoginNavigate = async () => { - const previousUrl = await this.routerService.getPreviousUrl(); + const previousUrl = this.routerService.getPreviousUrl(); if (previousUrl) { this.router.navigateByUrl(previousUrl); diff --git a/apps/browser/src/platform/popup/services/browser-router.service.ts b/apps/browser/src/platform/popup/services/browser-router.service.ts index ea81a855fc..b76588dde4 100644 --- a/apps/browser/src/platform/popup/services/browser-router.service.ts +++ b/apps/browser/src/platform/popup/services/browser-router.service.ts @@ -8,7 +8,9 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv providedIn: "root", }) export class BrowserRouterService { - constructor(router: Router, private stateService: StateService) { + private previousUrl: string = undefined; + + constructor(private router: Router, private stateService: StateService) { router.events .pipe(filter((e) => e instanceof NavigationEnd)) .subscribe((event: NavigationEnd) => { @@ -27,16 +29,11 @@ export class BrowserRouterService { }); } - async getPreviousUrl() { - return this.stateService.getPreviousUrl(); + getPreviousUrl() { + return this.previousUrl; } - // Check validity of previous url - async hasPreviousUrl() { - return (await this.getPreviousUrl()) != "/"; - } - - async setPreviousUrl(url: string) { - await this.stateService.setPreviousUrl(url); + setPreviousUrl(url: string) { + this.previousUrl = url; } } diff --git a/libs/common/src/platform/abstractions/state.service.ts b/libs/common/src/platform/abstractions/state.service.ts index f02df00060..4a2b515b74 100644 --- a/libs/common/src/platform/abstractions/state.service.ts +++ b/libs/common/src/platform/abstractions/state.service.ts @@ -524,17 +524,4 @@ export abstract class StateService { value: Record>, options?: StorageOptions ) => Promise; - /** - * fetches string value of the URL stored here, usually only called after SSO flows. - * @param options Defines the storage options for the URL; Defaults to Local Storage. - * @returns route called prior to SSO routing to organizations configured IdP. - */ - getPreviousUrl: (options?: StorageOptions) => Promise; - /** - * Store URL in local storage by default, but can be configured. Developed to handle - * SSO routing to organizations configured IdP. - * @param url URL of route - * @param options Defines the storage options for the URL; Defaults to Local Storage. - */ - setPreviousUrl: (url: string, options?: StorageOptions) => Promise; } diff --git a/libs/common/src/platform/models/domain/global-state.ts b/libs/common/src/platform/models/domain/global-state.ts index a43bf246bd..dfe3c6c417 100644 --- a/libs/common/src/platform/models/domain/global-state.ts +++ b/libs/common/src/platform/models/domain/global-state.ts @@ -37,5 +37,4 @@ export class GlobalState { enableBrowserIntegrationFingerprint?: boolean; enableDuckDuckGoBrowserIntegration?: boolean; region?: string; - previousUrl?: string; } diff --git a/libs/common/src/platform/services/state.service.ts b/libs/common/src/platform/services/state.service.ts index 174a953dfe..14ba4abfd3 100644 --- a/libs/common/src/platform/services/state.service.ts +++ b/libs/common/src/platform/services/state.service.ts @@ -2828,23 +2828,6 @@ export class StateService< ); } - async getPreviousUrl(options?: StorageOptions): Promise { - return ( - await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())) - )?.previousUrl; - } - - async setPreviousUrl(url: string, options?: StorageOptions): Promise { - const globals = await this.getGlobals( - this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()) - ); - globals.previousUrl = url; - await this.saveGlobals( - globals, - this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()) - ); - } - protected async getGlobals(options: StorageOptions): Promise { let globals: TGlobalState; if (this.useMemory(options.storageLocation)) { diff --git a/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts b/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts index eb69ad5ff1..813dbdb03c 100644 --- a/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts +++ b/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts @@ -83,8 +83,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); } - //TODO: uncomment this when working on the login flow ticket - // await userInterfaceSession.ensureUnlockedVault(); + await userInterfaceSession.ensureUnlockedVault(); const existingCipherIds = await this.findExcludedCredentials( params.excludeCredentialDescriptorList @@ -238,8 +237,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr let cipherOptions: CipherView[]; - //TODO: uncomment this when working on the login flow ticket - // await userInterfaceSession.ensureUnlockedVault(); + await userInterfaceSession.ensureUnlockedVault(); // eslint-disable-next-line no-empty if (params.allowCredentialDescriptorList?.length > 0) {