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 { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
|
||||||
import { LoginEmailServiceAbstraction, RegisterRouteService } from "@bitwarden/auth/common";
|
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 { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.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";
|
import { AccountSwitcherService } from "./account-switching/services/account-switcher.service";
|
||||||
|
|
||||||
@ -38,6 +42,8 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||||||
private accountSwitcherService: AccountSwitcherService,
|
private accountSwitcherService: AccountSwitcherService,
|
||||||
private registerRouteService: RegisterRouteService,
|
private registerRouteService: RegisterRouteService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
|
private configService: ConfigService,
|
||||||
|
private dialogService: DialogService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
@ -58,7 +64,13 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(
|
.pipe(
|
||||||
switchMap(async () => {
|
switchMap(async () => {
|
||||||
await this.setLoginEmailValues();
|
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$),
|
takeUntil(this.destroyed$),
|
||||||
)
|
)
|
||||||
|
@ -14,8 +14,10 @@ import {
|
|||||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
|
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
|
||||||
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.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 { 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 { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.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 { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.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 { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
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 { 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";
|
import { EnvironmentComponent } from "../environment.component";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "LoginComponent";
|
const BroadcasterSubscriptionId = "LoginComponent";
|
||||||
@ -76,6 +79,8 @@ export class LoginComponent extends BaseLoginComponent implements OnInit, OnDest
|
|||||||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||||
registerRouteService: RegisterRouteService,
|
registerRouteService: RegisterRouteService,
|
||||||
toastService: ToastService,
|
toastService: ToastService,
|
||||||
|
private configService: ConfigService,
|
||||||
|
private dialogService: DialogService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
devicesApiService,
|
devicesApiService,
|
||||||
@ -137,7 +142,35 @@ export class LoginComponent extends BaseLoginComponent implements OnInit, OnDest
|
|||||||
this.componentDestroyed$.complete();
|
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() {
|
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(
|
const [modal, childComponent] = await this.modalService.openViewRef(
|
||||||
EnvironmentComponent,
|
EnvironmentComponent,
|
||||||
this.environmentModal,
|
this.environmentModal,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
} as data"
|
} as data"
|
||||||
>
|
>
|
||||||
<div class="environment-selector-btn">
|
<div class="environment-selector-btn">
|
||||||
{{ "loggingInOn" | i18n }}:
|
{{ accessingString }}:
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
(click)="toggle(null)"
|
(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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { DialogService, FormFieldModule, SelectModule, ToastService } from "@bitwarden/components";
|
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.
|
* Component for selecting the environment to register with in the email verification registration flow.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<bit-dialog>
|
<bit-dialog>
|
||||||
<span bitDialogTitle> Self-hosted environment</span>
|
<span bitDialogTitle> Self-hosted environment</span>
|
||||||
<ng-container bitDialogContent>
|
<ng-container bitDialogContent>
|
||||||
|
REGISTRATION SELF HOSTED ENV CONFIG DIALOG
|
||||||
<bit-form-field>
|
<bit-form-field>
|
||||||
<bit-label>{{ "baseUrl" | i18n }}</bit-label>
|
<bit-label>{{ "baseUrl" | i18n }}</bit-label>
|
||||||
<input
|
<input
|
Loading…
Reference in New Issue
Block a user