mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
[PM-4612] [PM-6218] [PM-6219] Enable Duo redirect on Desktop Client (#7798)
* enable duo for desktop * added missing return path in main.ts * updated logic in component * removed switch added await; updated logic in main. * addressed subscription concerns in main; updated formatting in 2fa component * Update Duo case in locales
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, Inject, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
import { Component, Inject, NgZone, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import { TwoFactorComponent as BaseTwoFactorComponent } from "@bitwarden/angular/auth/components/two-factor.component";
|
||||
@@ -11,6 +11,7 @@ import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/
|
||||
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
||||
import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type";
|
||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -21,6 +22,8 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
|
||||
|
||||
import { TwoFactorOptionsComponent } from "./two-factor-options.component";
|
||||
|
||||
const BroadcasterSubscriptionId = "TwoFactorComponent";
|
||||
|
||||
@Component({
|
||||
selector: "app-two-factor",
|
||||
templateUrl: "two-factor.component.html",
|
||||
@@ -31,6 +34,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||
twoFactorOptionsModal: ViewContainerRef;
|
||||
|
||||
showingModal = false;
|
||||
duoCallbackSubscriptionEnabled: boolean = false;
|
||||
|
||||
constructor(
|
||||
loginStrategyService: LoginStrategyServiceAbstraction,
|
||||
@@ -40,8 +44,10 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
syncService: SyncService,
|
||||
environmentService: EnvironmentService,
|
||||
private broadcasterService: BroadcasterService,
|
||||
private modalService: ModalService,
|
||||
stateService: StateService,
|
||||
private ngZone: NgZone,
|
||||
route: ActivatedRoute,
|
||||
logService: LogService,
|
||||
twoFactorService: TwoFactorService,
|
||||
@@ -115,4 +121,25 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||
content.setAttribute("style", "width:335px");
|
||||
}
|
||||
}
|
||||
|
||||
protected override setupDuoResultListener() {
|
||||
if (!this.duoCallbackSubscriptionEnabled) {
|
||||
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
|
||||
await this.ngZone.run(async () => {
|
||||
if (message.command === "duoCallback") {
|
||||
this.token = message.code;
|
||||
await this.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
this.duoCallbackSubscriptionEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.duoCallbackSubscriptionEnabled) {
|
||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
||||
this.duoCallbackSubscriptionEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user