From cf9fb6cae71427f2f3b5c9e9eafd5dfbf55665c9 Mon Sep 17 00:00:00 2001
From: Frederic Eid <44294931+frederic11@users.noreply.github.com>
Date: Tue, 2 Jan 2024 17:47:41 -0500
Subject: [PATCH] Subscribe to configService.serverConfig$ to retrieve
DisableUserRegistration value and hide the button if true
---
.../src/app/auth/login/login.component.html | 18 +++++++++++-------
apps/web/src/app/auth/login/login.component.ts | 7 ++++++-
.../platform/models/data/server-config.data.ts | 2 ++
.../models/response/server-config.response.ts | 2 ++
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/apps/web/src/app/auth/login/login.component.html b/apps/web/src/app/auth/login/login.component.html
index 72315b1a4d..d1545b808b 100644
--- a/apps/web/src/app/auth/login/login.component.html
+++ b/apps/web/src/app/auth/login/login.component.html
@@ -68,13 +68,17 @@
-
-
-
- {{ "newAroundHere" | i18n }}
-
- {{ "createAccount" | i18n }}
-
+
+
+
+
+ {{ "newAroundHere" | i18n }}
+
+ {{ "createAccount" | i18n }}
+
+
+
+
diff --git a/apps/web/src/app/auth/login/login.component.ts b/apps/web/src/app/auth/login/login.component.ts
index 85a36be4d0..bcaca793f6 100644
--- a/apps/web/src/app/auth/login/login.component.ts
+++ b/apps/web/src/app/auth/login/login.component.ts
@@ -1,7 +1,7 @@
import { Component, NgZone, OnInit } from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
-import { takeUntil } from "rxjs";
+import { takeUntil, Observable } from "rxjs";
import { first } from "rxjs/operators";
import { LoginComponent as BaseLoginComponent } from "@bitwarden/angular/auth/components/login.component";
@@ -27,6 +27,8 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
+import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
+import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
import { flagEnabled } from "../../../utils/flags";
import { RouterService, StateService } from "../../core";
@@ -37,6 +39,8 @@ import { RouterService, StateService } from "../../core";
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class LoginComponent extends BaseLoginComponent implements OnInit {
+ protected serverConfig$: Observable
= this.configService.serverConfig$;
+
showResetPasswordAutoEnrollWarning = false;
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: ListResponse;
@@ -65,6 +69,7 @@ export class LoginComponent extends BaseLoginComponent implements OnInit {
formValidationErrorService: FormValidationErrorsService,
loginService: LoginService,
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
+ private configService: ConfigServiceAbstraction,
) {
super(
devicesApiService,
diff --git a/libs/common/src/platform/models/data/server-config.data.ts b/libs/common/src/platform/models/data/server-config.data.ts
index a4819f7567..6be634a133 100644
--- a/libs/common/src/platform/models/data/server-config.data.ts
+++ b/libs/common/src/platform/models/data/server-config.data.ts
@@ -57,6 +57,7 @@ export class EnvironmentServerConfigData {
identity: string;
notifications: string;
sso: string;
+ disableUserRegistration: boolean;
constructor(response: Partial) {
this.cloudRegion = response.cloudRegion;
@@ -65,6 +66,7 @@ export class EnvironmentServerConfigData {
this.identity = response.identity;
this.notifications = response.notifications;
this.sso = response.sso;
+ this.disableUserRegistration = response.disableUserRegistration;
}
static fromJSON(obj: Jsonify): EnvironmentServerConfigData {
diff --git a/libs/common/src/platform/models/response/server-config.response.ts b/libs/common/src/platform/models/response/server-config.response.ts
index f611acf6f4..015208e82a 100644
--- a/libs/common/src/platform/models/response/server-config.response.ts
+++ b/libs/common/src/platform/models/response/server-config.response.ts
@@ -30,6 +30,7 @@ export class EnvironmentServerConfigResponse extends BaseResponse {
identity: string;
notifications: string;
sso: string;
+ disableUserRegistration: boolean;
constructor(data: any = null) {
super(data);
@@ -44,6 +45,7 @@ export class EnvironmentServerConfigResponse extends BaseResponse {
this.identity = this.getResponseProperty("Identity");
this.notifications = this.getResponseProperty("Notifications");
this.sso = this.getResponseProperty("Sso");
+ this.disableUserRegistration = this.getResponseProperty("DisableUserRegistration");
}
}