diff --git a/apps/browser/src/auth/popup/home.component.ts b/apps/browser/src/auth/popup/home.component.ts index a75b21838c..65077da18b 100644 --- a/apps/browser/src/auth/popup/home.component.ts +++ b/apps/browser/src/auth/popup/home.component.ts @@ -20,9 +20,6 @@ export class HomeComponent implements OnInit, OnDestroy { private destroyed$: Subject = new Subject(); loginInitiated = false; - //use this to redirect somehwere else after login - redirectPath: string; - sessionId: string; formGroup = this.formBuilder.group({ email: ["", [Validators.required, Validators.email]], rememberEmail: [false], @@ -40,11 +37,6 @@ export class HomeComponent implements OnInit, OnDestroy { ) {} async ngOnInit(): Promise { - this.route?.queryParams.pipe(takeUntil(this.destroyed$)).subscribe((params) => { - this.redirectPath = params?.redirectPath; - this.sessionId = params?.sessionId; - }); - let savedEmail = this.loginService.getEmail(); const rememberEmail = this.loginService.getRememberEmail(); @@ -90,11 +82,12 @@ export class HomeComponent implements OnInit, OnDestroy { this.loginService.setEmail(this.formGroup.value.email); this.loginService.setRememberEmail(this.formGroup.value.rememberEmail); + // const decodedRedirectUrl = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl); + // console.log(decodedRedirectUrl, this.route); this.router.navigate(["login"], { queryParams: { email: this.formGroup.value.email, - redirectPath: this.redirectPath, - sessionId: this.sessionId, + redirectUrl: this.route.snapshot.queryParams.redirectUrl, }, }); } diff --git a/apps/browser/src/services/fido2/browser-fido2-user-interface.service.ts b/apps/browser/src/services/fido2/browser-fido2-user-interface.service.ts index 1dc056a7eb..3aa6bc8e65 100644 --- a/apps/browser/src/services/fido2/browser-fido2-user-interface.service.ts +++ b/apps/browser/src/services/fido2/browser-fido2-user-interface.service.ts @@ -352,7 +352,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi this.popout = await this.generatePopOut(authStatus); if (this.popout.type === "window") { - const popoutWindow = this.popout as { type: "window"; window: chrome.windows.Window }; + const popoutWindow = this.popout; this.windowClosed$ .pipe( filter((windowId) => popoutWindow.window.id === windowId), @@ -363,7 +363,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi this.abort(); }); } else if (this.popout.type === "tab") { - const popoutTab = this.popout as { type: "tab"; tab: chrome.tabs.Tab }; + const popoutTab = this.popout; this.tabClosed$ .pipe( filter((tabId) => popoutTab.tab.id === tabId), @@ -379,6 +379,15 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi } private async generatePopOut(authStatus: AuthenticationStatus) { + if (authStatus === AuthenticationStatus.Unlocked) { + const queryParams = new URLSearchParams({ sessionId: this.sessionId }); + return this.popupUtilsService.popOut( + null, + `popup/index.html?uilocation=popout#/fido2?${queryParams.toString()}`, + { center: true } + ); + } + let path: string; switch (authStatus) { @@ -389,21 +398,16 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi path = "lock"; break; default: - path = "fido2"; + throw new Error(`Unexpected auth status: ${authStatus}`); } - const queryParams = new URLSearchParams({ sessionId: this.sessionId }); - if ( - authStatus === AuthenticationStatus.LoggedOut || - authStatus === AuthenticationStatus.Locked - ) { - queryParams.append("redirectPath", "fido2"); - } + const redirectUrlParams = new URLSearchParams({ sessionId: this.sessionId }); + const redirectUrl = `/fido2?${redirectUrlParams.toString()}`; - const queryString = queryParams.toString(); + const queryParams = new URLSearchParams({ redirectUrl }); return this.popupUtilsService.popOut( null, - `popup/index.html?uilocation=popout#/${path}?${queryString}`, + `popup/index.html?uilocation=popout#/${path}?${queryParams.toString()}`, { center: true } ); } diff --git a/libs/angular/src/auth/components/two-factor.component.ts b/libs/angular/src/auth/components/two-factor.component.ts index d0890ba05a..a051443828 100644 --- a/libs/angular/src/auth/components/two-factor.component.ts +++ b/libs/angular/src/auth/components/two-factor.component.ts @@ -83,7 +83,7 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI } if (qParams.sessionId != null) { - this.sessionId = qParams?.sessionId; + this.sessionId = qParams.sessionId; } }); 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 29e8d628b6..8c3cd1e66f 100644 --- a/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts +++ b/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts @@ -84,7 +84,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr } //TODO: uncomment this when working on the login flow ticket - // await userInterfaceSession.ensureUnlockedVault(); + await userInterfaceSession.ensureUnlockedVault(); const existingCipherIds = await this.findExcludedCredentials( params.excludeCredentialDescriptorList @@ -239,7 +239,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) {