1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-30 22:41:33 +01:00

Merged branch with master and fixed conflicts

This commit is contained in:
gbubemismith 2023-08-24 15:45:17 -04:00
parent 91324876c6
commit b0dadca574
No known key found for this signature in database
4 changed files with 23 additions and 25 deletions

View File

@ -32,6 +32,7 @@ const BroadcasterSubscriptionId = "TwoFactorComponent";
})
export class TwoFactorComponent extends BaseTwoFactorComponent {
showNewWindowMessage = false;
redirectUrl: string;
constructor(
authService: AuthService,
@ -74,6 +75,16 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
syncService.fullSync(true);
};
super.onSuccessfulLoginNavigate = async () => {
// The `redirectUrl` parameter determines the target route after a successful login.
// If provided in the URL's query parameters, the user will be redirected
// to the specified path once they are authenticated.
if (this.route.snapshot.queryParams.redirectUrl) {
this.redirectUrl = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl);
this.router.navigateByUrl(this.redirectUrl);
}
};
super.onSuccessfulLoginTde = async () => {
syncService.fullSync(true);
};

View File

@ -1,4 +1,3 @@
import type { NgZone } from "@angular/core";
import { Observable } from "rxjs";
import { DeviceType } from "@bitwarden/common/enums";
@ -245,22 +244,20 @@ export class BrowserApi {
}
/**
* Creates an observable that listens for messages. If an Angular zone is provided,
* ensures that the message processing runs within that zone, triggering change detection.
* Creates an observable that listens for messages. While this observable might
* operate outside the Angular zone, it's recommended to pipe it with the
* utility function `runInsideAngular` to ensure proper triggering of change detection
* and other zone-related behaviors.
*
* @see /libs/angular/src/utils/run-inside-angular.operator.ts
*
* This solution was devised to address an issue in the `Fido2Component`, where the
* original message listener operated outside the Angular zone.
*
* @param {NgZone} [zone] - An optional Angular zone to ensure UI updates and change
* detection are triggered. If omitted, operates outside the Angular zone.
*/
static messageListener$(zone?: NgZone) {
static messageListener$() {
return new Observable<unknown>((subscriber) => {
const handler = (message: unknown) => {
if (zone) {
zone.run(() => subscriber.next(message));
} else {
subscriber.next(message);
}
};
chrome.runtime.onMessage.addListener(handler);
return () => chrome.runtime.onMessage.removeListener(handler);

View File

@ -12,6 +12,7 @@ import {
takeUntil,
} from "rxjs";
import { runInsideAngular } from "@bitwarden/angular/utils/run-inside-angular.operator";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { PasswordRepromptService } from "@bitwarden/common/vault/abstractions/password-reprompt.service";
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
@ -58,11 +59,8 @@ export class Fido2Component implements OnInit, OnDestroy {
map((queryParamMap) => queryParamMap.get("sessionId"))
);
combineLatest([
sessionId$,
BrowserApi.messageListener$(this.ngZone) as Observable<BrowserFido2Message>,
])
.pipe(takeUntil(this.destroy$))
combineLatest([sessionId$, BrowserApi.messageListener$() as Observable<BrowserFido2Message>])
.pipe(runInsideAngular(this.ngZone), takeUntil(this.destroy$))
.subscribe(([sessionId, message]) => {
this.sessionId = sessionId;
if (message.type === "NewSessionCreatedRequest" && message.sessionId !== sessionId) {

View File

@ -45,7 +45,6 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI
formPromise: Promise<any>;
emailPromise: Promise<any>;
orgIdentifier: string = null;
redirectUrl: string;
onSuccessfulLogin: () => Promise<void>;
onSuccessfulLoginNavigate: () => Promise<void>;
@ -207,13 +206,6 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI
}
async doSubmit() {
// The `redirectUrl` parameter determines the target route after a successful login.
// If provided in the URL's query parameters, the user will be redirected
// to the specified path once they are authenticated.
if (this.route.snapshot.queryParams.redirectUrl) {
this.successRoute = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl);
}
this.formPromise = this.authService.logInTwoFactor(
new TokenTwoFactorRequest(this.selectedProviderType, this.token, this.remember),
this.captchaToken