mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
change orgId input to masterPasswordPolicyOptions (#9833)
This commit is contained in:
@@ -3,17 +3,12 @@ import { ReactiveFormsModule, FormBuilder, Validators } from "@angular/forms";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
||||
import {
|
||||
DEFAULT_KDF_CONFIG,
|
||||
PBKDF2KdfConfig,
|
||||
} from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||
import { DEFAULT_KDF_CONFIG } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { MasterKey } from "@bitwarden/common/types/key";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
ButtonModule,
|
||||
@@ -29,12 +24,7 @@ import { InputsFieldMatch } from "../../../../angular/src/auth/validators/inputs
|
||||
import { SharedModule } from "../../../../components/src/shared";
|
||||
import { PasswordCalloutComponent } from "../password-callout/password-callout.component";
|
||||
|
||||
export interface PasswordInputResult {
|
||||
masterKey: MasterKey;
|
||||
masterKeyHash: string;
|
||||
kdfConfig: PBKDF2KdfConfig;
|
||||
hint: string;
|
||||
}
|
||||
import { PasswordInputResult } from "./password-input-result";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -58,14 +48,13 @@ export class InputPasswordComponent implements OnInit {
|
||||
|
||||
@Input({ required: true }) email: string;
|
||||
@Input() protected buttonText: string;
|
||||
@Input() private orgId: string;
|
||||
@Input() masterPasswordPolicyOptions: MasterPasswordPolicyOptions | null = null;
|
||||
|
||||
private minHintLength = 0;
|
||||
protected maxHintLength = 50;
|
||||
|
||||
protected minPasswordLength = Utils.minimumPasswordLength;
|
||||
protected minPasswordMsg = "";
|
||||
protected masterPasswordPolicy: MasterPasswordPolicyOptions;
|
||||
protected passwordStrengthResult: any;
|
||||
protected showErrorSummary = false;
|
||||
protected showPassword = false;
|
||||
@@ -106,18 +95,16 @@ export class InputPasswordComponent implements OnInit {
|
||||
private i18nService: I18nService,
|
||||
private policyService: PolicyService,
|
||||
private toastService: ToastService,
|
||||
private policyApiService: PolicyApiServiceAbstraction,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.masterPasswordPolicy = await this.policyApiService.getMasterPasswordPolicyOptsForOrgUser(
|
||||
this.orgId,
|
||||
);
|
||||
|
||||
if (this.masterPasswordPolicy != null && this.masterPasswordPolicy.minLength > 0) {
|
||||
if (
|
||||
this.masterPasswordPolicyOptions != null &&
|
||||
this.masterPasswordPolicyOptions.minLength > 0
|
||||
) {
|
||||
this.minPasswordMsg = this.i18nService.t(
|
||||
"characterMinimum",
|
||||
this.masterPasswordPolicy.minLength,
|
||||
this.masterPasswordPolicyOptions.minLength,
|
||||
);
|
||||
} else {
|
||||
this.minPasswordMsg = this.i18nService.t("characterMinimum", this.minPasswordLength);
|
||||
@@ -157,11 +144,11 @@ export class InputPasswordComponent implements OnInit {
|
||||
|
||||
// Check if password meets org policy requirements
|
||||
if (
|
||||
this.masterPasswordPolicy != null &&
|
||||
this.masterPasswordPolicyOptions != null &&
|
||||
!this.policyService.evaluateMasterPassword(
|
||||
this.passwordStrengthResult.score,
|
||||
password,
|
||||
this.masterPasswordPolicy,
|
||||
this.masterPasswordPolicyOptions,
|
||||
)
|
||||
) {
|
||||
this.toastService.showToast({
|
||||
|
||||
Reference in New Issue
Block a user