2018-04-11 05:49:46 +02:00
|
|
|
import { Component } from "@angular/core";
|
2023-05-29 19:55:37 +02:00
|
|
|
import { ActivatedRoute, Router } from "@angular/router";
|
2018-04-04 16:08:30 +02:00
|
|
|
|
2023-02-06 22:53:37 +01:00
|
|
|
import { TwoFactorOptionsComponent as BaseTwoFactorOptionsComponent } from "@bitwarden/angular/auth/components/two-factor-options.component";
|
2022-06-14 17:10:53 +02:00
|
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
2023-02-06 22:53:37 +01:00
|
|
|
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
2018-04-04 16:08:30 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-two-factor-options",
|
2018-04-06 17:48:45 +02:00
|
|
|
templateUrl: "two-factor-options.component.html",
|
2018-04-04 16:08:30 +02:00
|
|
|
})
|
|
|
|
export class TwoFactorOptionsComponent extends BaseTwoFactorOptionsComponent {
|
|
|
|
constructor(
|
2022-02-08 00:06:37 +01:00
|
|
|
twoFactorService: TwoFactorService,
|
2018-04-04 16:08:30 +02:00
|
|
|
router: Router,
|
|
|
|
i18nService: I18nService,
|
2023-05-29 19:55:37 +02:00
|
|
|
platformUtilsService: PlatformUtilsService,
|
|
|
|
private activatedRoute: ActivatedRoute
|
2018-04-04 16:08:30 +02:00
|
|
|
) {
|
2022-02-08 00:06:37 +01:00
|
|
|
super(twoFactorService, router, i18nService, platformUtilsService, window);
|
2018-04-04 16:08:30 +02:00
|
|
|
}
|
2018-04-04 20:19:44 +02:00
|
|
|
|
2023-05-29 19:55:37 +02:00
|
|
|
close() {
|
|
|
|
this.navigateTo2FA();
|
|
|
|
}
|
|
|
|
|
2018-04-04 20:19:44 +02:00
|
|
|
choose(p: any) {
|
|
|
|
super.choose(p);
|
2022-02-08 00:06:37 +01:00
|
|
|
this.twoFactorService.setSelectedProvider(p.type);
|
2023-05-29 19:55:37 +02:00
|
|
|
|
|
|
|
this.navigateTo2FA();
|
|
|
|
}
|
|
|
|
|
|
|
|
navigateTo2FA() {
|
|
|
|
const sso = this.activatedRoute.snapshot.queryParamMap.get("sso") === "true";
|
|
|
|
|
|
|
|
if (sso) {
|
|
|
|
// Persist SSO flag back to the 2FA comp if it exists
|
|
|
|
// in order for successful login logic to work properly for
|
|
|
|
// SSO + 2FA in browser extension
|
|
|
|
this.router.navigate(["2fa"], { queryParams: { sso: true } });
|
|
|
|
} else {
|
|
|
|
this.router.navigate(["2fa"]);
|
|
|
|
}
|
2018-04-04 20:19:44 +02:00
|
|
|
}
|
2018-04-04 16:08:30 +02:00
|
|
|
}
|