mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-17 07:15:13 +02:00
Reimplement RegistrationSelfHostedEnvConfigDialogComponent
This commit is contained in:
parent
0f525fa9bc
commit
c8e404cb9b
@ -5,9 +5,13 @@ import { Subject, firstValueFrom, switchMap, takeUntil } from "rxjs";
|
||||
|
||||
import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
|
||||
import { LoginEmailServiceAbstraction, RegisterRouteService } from "@bitwarden/auth/common";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
import { ToastService, DialogService } from "@bitwarden/components";
|
||||
|
||||
import { RegistrationSelfHostedEnvConfigDialogComponent } from "../../../../../libs/auth/src/angular/registration/registration-self-hosted-env-config-dialog/registration-self-hosted-env-config-dialog.component";
|
||||
|
||||
import { AccountSwitcherService } from "./account-switching/services/account-switcher.service";
|
||||
|
||||
@ -38,6 +42,8 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
private accountSwitcherService: AccountSwitcherService,
|
||||
private registerRouteService: RegisterRouteService,
|
||||
private toastService: ToastService,
|
||||
private configService: ConfigService,
|
||||
private dialogService: DialogService,
|
||||
) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
@ -58,7 +64,13 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
.pipe(
|
||||
switchMap(async () => {
|
||||
await this.setLoginEmailValues();
|
||||
await this.router.navigate(["environment"]);
|
||||
if (
|
||||
await this.configService.getFeatureFlag(FeatureFlag.UnauthenticatedExtensionUIRefresh)
|
||||
) {
|
||||
await RegistrationSelfHostedEnvConfigDialogComponent.open(this.dialogService);
|
||||
} else {
|
||||
await this.router.navigate(["environment"]);
|
||||
}
|
||||
}),
|
||||
takeUntil(this.destroyed$),
|
||||
)
|
||||
|
@ -14,8 +14,10 @@ import {
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
|
||||
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
|
||||
import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@ -25,9 +27,10 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||
|
||||
import { RegistrationSelfHostedEnvConfigDialogComponent } from "../../../../../libs/auth/src/angular/registration/registration-self-hosted-env-config-dialog/registration-self-hosted-env-config-dialog.component";
|
||||
import { EnvironmentComponent } from "../environment.component";
|
||||
|
||||
const BroadcasterSubscriptionId = "LoginComponent";
|
||||
@ -76,6 +79,8 @@ export class LoginComponent extends BaseLoginComponent implements OnInit, OnDest
|
||||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||
registerRouteService: RegisterRouteService,
|
||||
toastService: ToastService,
|
||||
private configService: ConfigService,
|
||||
private dialogService: DialogService,
|
||||
) {
|
||||
super(
|
||||
devicesApiService,
|
||||
@ -137,7 +142,35 @@ export class LoginComponent extends BaseLoginComponent implements OnInit, OnDest
|
||||
this.componentDestroyed$.complete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the environment configuration dialog.
|
||||
* If the feature flag is enabled, it will open the refreshed environment configuration dialog.
|
||||
* Otherwise, it will open the environment configuration dialog.
|
||||
*/
|
||||
async settings() {
|
||||
if (await this.configService.getFeatureFlag(FeatureFlag.UnauthenticatedExtensionUIRefresh)) {
|
||||
await this.showRefreshedEnvConfigDialog();
|
||||
} else {
|
||||
await this.showEnvConfigDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the refreshed environment configuration dialog (when the UnauthenticatedExtensionUIRefresh flag is true).
|
||||
*/
|
||||
async showRefreshedEnvConfigDialog() {
|
||||
this.showingModal = true;
|
||||
const wasSaved = await RegistrationSelfHostedEnvConfigDialogComponent.open(this.dialogService);
|
||||
this.showingModal = false;
|
||||
if (wasSaved) {
|
||||
await this.getLoginWithDevice(this.loggedEmail);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the environment configuration dialog.
|
||||
*/
|
||||
async showEnvConfigDialog() {
|
||||
const [modal, childComponent] = await this.modalService.openViewRef(
|
||||
EnvironmentComponent,
|
||||
this.environmentModal,
|
||||
|
@ -4,7 +4,7 @@
|
||||
} as data"
|
||||
>
|
||||
<div class="environment-selector-btn">
|
||||
{{ "loggingInOn" | i18n }}:
|
||||
{{ accessingString }}:
|
||||
<button
|
||||
type="button"
|
||||
(click)="toggle(null)"
|
||||
|
@ -15,7 +15,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { DialogService, FormFieldModule, SelectModule, ToastService } from "@bitwarden/components";
|
||||
|
||||
import { RegistrationSelfHostedEnvConfigDialogComponent } from "./registration-self-hosted-env-config-dialog.component";
|
||||
import { RegistrationSelfHostedEnvConfigDialogComponent } from "../registration-self-hosted-env-config-dialog/registration-self-hosted-env-config-dialog.component";
|
||||
|
||||
/**
|
||||
* Component for selecting the environment to register with in the email verification registration flow.
|
||||
|
@ -2,6 +2,7 @@
|
||||
<bit-dialog>
|
||||
<span bitDialogTitle> Self-hosted environment</span>
|
||||
<ng-container bitDialogContent>
|
||||
REGISTRATION SELF HOSTED ENV CONFIG DIALOG
|
||||
<bit-form-field>
|
||||
<bit-label>{{ "baseUrl" | i18n }}</bit-label>
|
||||
<input
|
Loading…
Reference in New Issue
Block a user