1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-15 10:35:20 +01:00

Code cleanup to remove sessionId from login component

This commit is contained in:
gbubemismith 2023-08-22 16:22:45 -04:00
parent 905ac1987c
commit ef4a1d9b7b
No known key found for this signature in database
4 changed files with 22 additions and 25 deletions

View File

@ -20,9 +20,6 @@ export class HomeComponent implements OnInit, OnDestroy {
private destroyed$: Subject<void> = 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<void> {
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,
},
});
}

View File

@ -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 }
);
}

View File

@ -83,7 +83,7 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI
}
if (qParams.sessionId != null) {
this.sessionId = qParams?.sessionId;
this.sessionId = qParams.sessionId;
}
});

View File

@ -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) {