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