Add server settings to old views
This commit is contained in:
parent
e21c0fdd9a
commit
74816a3818
|
@ -28,7 +28,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<p class="createAccountLink">
|
<p class="createAccountLink" *ngIf="!(isUserRegistrationDisabled$ | async)">
|
||||||
{{ "newAroundHere" | i18n }}
|
{{ "newAroundHere" | i18n }}
|
||||||
<a [routerLink]="registerRoute$ | async" (click)="setLoginEmailValues()">{{
|
<a [routerLink]="registerRoute$ | async" (click)="setLoginEmailValues()">{{
|
||||||
"createAccount" | i18n
|
"createAccount" | i18n
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||||
import { FormBuilder, Validators } from "@angular/forms";
|
import { FormBuilder, Validators } from "@angular/forms";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { Subject, firstValueFrom, switchMap, takeUntil } from "rxjs";
|
import { Observable, Subject, firstValueFrom, switchMap, takeUntil, map, tap } 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";
|
||||||
|
@ -10,6 +10,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { AccountSwitcherService } from "./account-switching/services/account-switcher.service";
|
import { AccountSwitcherService } from "./account-switching/services/account-switcher.service";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-home",
|
selector: "app-home",
|
||||||
|
@ -18,6 +19,7 @@ import { AccountSwitcherService } from "./account-switching/services/account-swi
|
||||||
export class HomeComponent implements OnInit, OnDestroy {
|
export class HomeComponent implements OnInit, OnDestroy {
|
||||||
@ViewChild(EnvironmentSelectorComponent, { static: true })
|
@ViewChild(EnvironmentSelectorComponent, { static: true })
|
||||||
environmentSelector!: EnvironmentSelectorComponent;
|
environmentSelector!: EnvironmentSelectorComponent;
|
||||||
|
isUserRegistrationDisabled$: Observable<boolean>;
|
||||||
private destroyed$: Subject<void> = new Subject();
|
private destroyed$: Subject<void> = new Subject();
|
||||||
|
|
||||||
loginInitiated = false;
|
loginInitiated = false;
|
||||||
|
@ -38,6 +40,7 @@ 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 serverSettingsService: ServerSettingsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
@ -63,6 +66,12 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||||
takeUntil(this.destroyed$),
|
takeUntil(this.destroyed$),
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
|
this.isUserRegistrationDisabled$ = this.serverSettingsService.isUserRegistrationDisabled$.pipe(
|
||||||
|
map((value: boolean | null) => value ?? false),
|
||||||
|
tap((value: boolean) => console.log("isUserRegistrationDisabled:", value)),
|
||||||
|
takeUntil(this.destroyed$),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Component, NgZone, OnInit } from "@angular/core";
|
import { Component, NgZone, OnInit } from "@angular/core";
|
||||||
import { FormBuilder } from "@angular/forms";
|
import { FormBuilder } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { firstValueFrom } from "rxjs";
|
import { firstValueFrom, Observable } from "rxjs";
|
||||||
|
|
||||||
import { LoginComponentV1 as BaseLoginComponent } from "@bitwarden/angular/auth/components/login-v1.component";
|
import { LoginComponentV1 as BaseLoginComponent } from "@bitwarden/angular/auth/components/login-v1.component";
|
||||||
import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstractions/form-validation-errors.service";
|
import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstractions/form-validation-errors.service";
|
||||||
|
@ -26,6 +26,7 @@ import { ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
|
||||||
import { flagEnabled } from "../../platform/flags";
|
import { flagEnabled } from "../../platform/flags";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login",
|
selector: "app-login",
|
||||||
|
@ -55,6 +56,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
||||||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||||
registerRouteService: RegisterRouteService,
|
registerRouteService: RegisterRouteService,
|
||||||
toastService: ToastService,
|
toastService: ToastService,
|
||||||
|
serverSettingsService: ServerSettingsService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
devicesApiService,
|
devicesApiService,
|
||||||
|
@ -77,6 +79,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
||||||
webAuthnLoginService,
|
webAuthnLoginService,
|
||||||
registerRouteService,
|
registerRouteService,
|
||||||
toastService,
|
toastService,
|
||||||
|
serverSettingsService,
|
||||||
);
|
);
|
||||||
this.onSuccessfulLogin = async () => {
|
this.onSuccessfulLogin = async () => {
|
||||||
await syncService.fullSync(true);
|
await syncService.fullSync(true);
|
||||||
|
|
|
@ -142,6 +142,7 @@ import { VaultFilterService } from "../../vault/services/vault-filter.service";
|
||||||
import { DebounceNavigationService } from "./debounce-navigation.service";
|
import { DebounceNavigationService } from "./debounce-navigation.service";
|
||||||
import { InitService } from "./init.service";
|
import { InitService } from "./init.service";
|
||||||
import { PopupCloseWarningService } from "./popup-close-warning.service";
|
import { PopupCloseWarningService } from "./popup-close-warning.service";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
|
||||||
const OBSERVABLE_LARGE_OBJECT_MEMORY_STORAGE = new SafeInjectionToken<
|
const OBSERVABLE_LARGE_OBJECT_MEMORY_STORAGE = new SafeInjectionToken<
|
||||||
AbstractStorageService & ObservableStorageService
|
AbstractStorageService & ObservableStorageService
|
||||||
|
@ -618,6 +619,11 @@ const safeProviders: SafeProvider[] = [
|
||||||
useClass: ExtensionAnonLayoutWrapperDataService,
|
useClass: ExtensionAnonLayoutWrapperDataService,
|
||||||
deps: [],
|
deps: [],
|
||||||
}),
|
}),
|
||||||
|
safeProvider({
|
||||||
|
provide: ServerSettingsService,
|
||||||
|
useClass: ServerSettingsService,
|
||||||
|
deps: [ConfigService],
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -119,6 +119,8 @@ import { DesktopThemeStateService } from "./desktop-theme.service";
|
||||||
import { InitService } from "./init.service";
|
import { InitService } from "./init.service";
|
||||||
import { NativeMessagingManifestService } from "./native-messaging-manifest.service";
|
import { NativeMessagingManifestService } from "./native-messaging-manifest.service";
|
||||||
import { RendererCryptoFunctionService } from "./renderer-crypto-function.service";
|
import { RendererCryptoFunctionService } from "./renderer-crypto-function.service";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
|
|
||||||
const RELOAD_CALLBACK = new SafeInjectionToken<() => any>("RELOAD_CALLBACK");
|
const RELOAD_CALLBACK = new SafeInjectionToken<() => any>("RELOAD_CALLBACK");
|
||||||
|
|
||||||
|
@ -352,6 +354,11 @@ const safeProviders: SafeProvider[] = [
|
||||||
useClass: LoginEmailService,
|
useClass: LoginEmailService,
|
||||||
deps: [AccountService, AuthService, StateProvider],
|
deps: [AccountService, AuthService, StateProvider],
|
||||||
}),
|
}),
|
||||||
|
safeProvider({
|
||||||
|
provide: ServerSettingsService,
|
||||||
|
useClass: ServerSettingsService,
|
||||||
|
deps: [ConfigService],
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sub-options">
|
<div class="sub-options" *ngIf="!(isUserRegistrationDisabled$ | async)">
|
||||||
<p class="no-margin">{{ "newAroundHere" | i18n }}</p>
|
<p class="no-margin">{{ "newAroundHere" | i18n }}</p>
|
||||||
<button type="button" class="text text-primary" [routerLink]="registerRoute$ | async">
|
<button type="button" class="text text-primary" [routerLink]="registerRoute$ | async">
|
||||||
{{ "createAccount" | i18n }}
|
{{ "createAccount" | i18n }}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Component, NgZone, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
import { Component, NgZone, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
||||||
import { FormBuilder } from "@angular/forms";
|
import { FormBuilder } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { Subject, takeUntil } from "rxjs";
|
import { Subject, takeUntil, Observable } from "rxjs";
|
||||||
|
import { map } from "rxjs/operators";
|
||||||
|
|
||||||
import { LoginComponentV1 as BaseLoginComponent } from "@bitwarden/angular/auth/components/login-v1.component";
|
import { LoginComponentV1 as BaseLoginComponent } from "@bitwarden/angular/auth/components/login-v1.component";
|
||||||
import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstractions/form-validation-errors.service";
|
import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstractions/form-validation-errors.service";
|
||||||
|
@ -27,6 +28,7 @@ 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 { ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
|
||||||
import { EnvironmentComponent } from "../environment.component";
|
import { EnvironmentComponent } from "../environment.component";
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
|
||||||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||||
registerRouteService: RegisterRouteService,
|
registerRouteService: RegisterRouteService,
|
||||||
toastService: ToastService,
|
toastService: ToastService,
|
||||||
|
serverSettingsService: ServerSettingsService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
devicesApiService,
|
devicesApiService,
|
||||||
|
@ -98,6 +101,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
|
||||||
webAuthnLoginService,
|
webAuthnLoginService,
|
||||||
registerRouteService,
|
registerRouteService,
|
||||||
toastService,
|
toastService,
|
||||||
|
serverSettingsService,
|
||||||
);
|
);
|
||||||
this.onSuccessfulLogin = () => {
|
this.onSuccessfulLogin = () => {
|
||||||
return syncService.fullSync(true);
|
return syncService.fullSync(true);
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<p class="tw-m-0 tw-text-sm">
|
<p class="tw-m-0 tw-text-sm" *ngIf="!(isUserRegistrationDisabled$ | async)">
|
||||||
{{ "newAroundHere" | i18n }}
|
{{ "newAroundHere" | i18n }}
|
||||||
<!-- Two notes:
|
<!-- Two notes:
|
||||||
(1) We check the value and validity of email so we don't send an invalid email to autofill
|
(1) We check the value and validity of email so we don't send an invalid email to autofill
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/pass
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
|
||||||
import { flagEnabled } from "../../../utils/flags";
|
import { flagEnabled } from "../../../utils/flags";
|
||||||
import { RouterService } from "../../core";
|
import { RouterService } from "../../core";
|
||||||
|
@ -74,6 +75,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
||||||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||||
registerRouteService: RegisterRouteService,
|
registerRouteService: RegisterRouteService,
|
||||||
toastService: ToastService,
|
toastService: ToastService,
|
||||||
|
serverSettingsService: ServerSettingsService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
devicesApiService,
|
devicesApiService,
|
||||||
|
@ -96,6 +98,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
||||||
webAuthnLoginService,
|
webAuthnLoginService,
|
||||||
registerRouteService,
|
registerRouteService,
|
||||||
toastService,
|
toastService,
|
||||||
|
serverSettingsService,
|
||||||
);
|
);
|
||||||
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
||||||
this.showPasswordless = flagEnabled("showPasswordless");
|
this.showPasswordless = flagEnabled("showPasswordless");
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Directive, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
import { Directive, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||||
import { FormBuilder, Validators } from "@angular/forms";
|
import { FormBuilder, Validators } from "@angular/forms";
|
||||||
import { ActivatedRoute, NavigationSkipped, Router } from "@angular/router";
|
import { ActivatedRoute, NavigationSkipped, Router } from "@angular/router";
|
||||||
import { Subject, firstValueFrom, of } from "rxjs";
|
import { Subject, firstValueFrom, of, Observable } from "rxjs";
|
||||||
import { switchMap, take, takeUntil } from "rxjs/operators";
|
import { switchMap, take, takeUntil, map } from "rxjs/operators";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LoginStrategyServiceAbstraction,
|
LoginStrategyServiceAbstraction,
|
||||||
|
@ -26,6 +26,7 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { ServerSettingsService } from "@bitwarden/common/platform/services/server-settings.service";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AllValidationErrors,
|
AllValidationErrors,
|
||||||
|
@ -68,6 +69,7 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
|
||||||
// TODO: remove when email verification flag is removed
|
// TODO: remove when email verification flag is removed
|
||||||
protected registerRoute$ = this.registerRouteService.registerRoute$();
|
protected registerRoute$ = this.registerRouteService.registerRoute$();
|
||||||
protected forcePasswordResetRoute = "update-temp-password";
|
protected forcePasswordResetRoute = "update-temp-password";
|
||||||
|
protected isUserRegistrationDisabled$: Observable<boolean>;
|
||||||
|
|
||||||
protected destroy$ = new Subject<void>();
|
protected destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
@ -96,11 +98,17 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
|
||||||
protected webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
protected webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||||
protected registerRouteService: RegisterRouteService,
|
protected registerRouteService: RegisterRouteService,
|
||||||
protected toastService: ToastService,
|
protected toastService: ToastService,
|
||||||
|
protected serverSettingsService: ServerSettingsService,
|
||||||
) {
|
) {
|
||||||
super(environmentService, i18nService, platformUtilsService, toastService);
|
super(environmentService, i18nService, platformUtilsService, toastService);
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
this.isUserRegistrationDisabled$ = this.serverSettingsService.isUserRegistrationDisabled$.pipe(
|
||||||
|
map((value) => value ?? false),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
);
|
||||||
|
|
||||||
this.route?.queryParams
|
this.route?.queryParams
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((params) => {
|
switchMap((params) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { LinkModule } from "@bitwarden/components";
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, JslibModule, LinkModule, RouterModule],
|
imports: [CommonModule, JslibModule, LinkModule, RouterModule],
|
||||||
template: `
|
template: `
|
||||||
<div class="tw-text-center" *ngIf="!isUserRegistrationDisabled">
|
<div class="tw-text-center" *ngIf="!(isUserRegistrationDisabled$ | async)">
|
||||||
{{ "newToBitwarden" | i18n }}
|
{{ "newToBitwarden" | i18n }}
|
||||||
<a bitLink [routerLink]="registerRoute$ | async">{{ "createAccount" | i18n }}</a>
|
<a bitLink [routerLink]="registerRoute$ | async">{{ "createAccount" | i18n }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,5 +24,5 @@ export class LoginSecondaryContentComponent {
|
||||||
// TODO: remove when email verification flag is removed
|
// TODO: remove when email verification flag is removed
|
||||||
protected registerRoute$ = this.registerRouteService.registerRoute$();
|
protected registerRoute$ = this.registerRouteService.registerRoute$();
|
||||||
|
|
||||||
protected isUserRegistrationDisabled = this.serverSettingsService.isUserRegistrationDisabled$;
|
protected isUserRegistrationDisabled$ = this.serverSettingsService.isUserRegistrationDisabled$;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue