mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
Refactored the connect method be seperating to the pop out logic to a seperate method
This commit is contained in:
@@ -357,34 +357,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|||||||
);
|
);
|
||||||
|
|
||||||
const authStatus = await this.authService.getAuthStatus();
|
const authStatus = await this.authService.getAuthStatus();
|
||||||
if (authStatus === AuthenticationStatus.LoggedOut) {
|
this.popout = await this.generatePopOut(authStatus);
|
||||||
const queryParams = new URLSearchParams({
|
|
||||||
sessionId: this.sessionId,
|
|
||||||
redirectPath: "fido2",
|
|
||||||
}).toString();
|
|
||||||
this.popout = await this.popupUtilsService.popOut(
|
|
||||||
null,
|
|
||||||
`popup/index.html?uilocation=popout#/home?${queryParams}`,
|
|
||||||
{ center: true }
|
|
||||||
);
|
|
||||||
} else if (authStatus === AuthenticationStatus.Locked) {
|
|
||||||
const queryParams = new URLSearchParams({
|
|
||||||
sessionId: this.sessionId,
|
|
||||||
redirectPath: "fido2",
|
|
||||||
}).toString();
|
|
||||||
this.popout = await this.popupUtilsService.popOut(
|
|
||||||
null,
|
|
||||||
`popup/index.html?uilocation=popout#/lock?${queryParams}`,
|
|
||||||
{ center: true }
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const queryParams = new URLSearchParams({ sessionId: this.sessionId }).toString();
|
|
||||||
this.popout = await this.popupUtilsService.popOut(
|
|
||||||
null,
|
|
||||||
`popup/index.html?uilocation=popout#/fido2?${queryParams}`,
|
|
||||||
{ center: true }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.popout.type === "window") {
|
if (this.popout.type === "window") {
|
||||||
const popoutWindow = this.popout as { type: "window"; window: chrome.windows.Window };
|
const popoutWindow = this.popout as { type: "window"; window: chrome.windows.Window };
|
||||||
@@ -412,4 +385,34 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|||||||
|
|
||||||
await connectPromise;
|
await connectPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async generatePopOut(authStatus: AuthenticationStatus) {
|
||||||
|
let path: string;
|
||||||
|
|
||||||
|
switch (authStatus) {
|
||||||
|
case AuthenticationStatus.LoggedOut:
|
||||||
|
path = "home";
|
||||||
|
break;
|
||||||
|
case AuthenticationStatus.Locked:
|
||||||
|
path = "lock";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
path = "fido2";
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParams = new URLSearchParams({ sessionId: this.sessionId });
|
||||||
|
if (
|
||||||
|
authStatus === AuthenticationStatus.LoggedOut ||
|
||||||
|
authStatus === AuthenticationStatus.Locked
|
||||||
|
) {
|
||||||
|
queryParams.append("redirectPath", "fido2");
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryString = queryParams.toString();
|
||||||
|
return this.popupUtilsService.popOut(
|
||||||
|
null,
|
||||||
|
`popup/index.html?uilocation=popout#/${path}?${queryString}`,
|
||||||
|
{ center: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user