mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PM-14964] revert passphrase minimum (#12019)
* revert passphrase minimum * add recommendation text to browser refresh; hide hint text when value exceeds recommendation * migrate validators to generator configuration
This commit is contained in:
@@ -82,9 +82,24 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy {
|
||||
const settings = await this.generatorService.settings(Generators.passphrase, { singleUserId$ });
|
||||
|
||||
// skips reactive event emissions to break a subscription cycle
|
||||
settings.pipe(takeUntil(this.destroyed$)).subscribe((s) => {
|
||||
this.settings.patchValue(s, { emitEvent: false });
|
||||
});
|
||||
settings.withConstraints$
|
||||
.pipe(takeUntil(this.destroyed$))
|
||||
.subscribe(({ state, constraints }) => {
|
||||
this.settings.patchValue(state, { emitEvent: false });
|
||||
|
||||
let boundariesHint = this.i18nService.t(
|
||||
"spinboxBoundariesHint",
|
||||
constraints.numWords.min?.toString(),
|
||||
constraints.numWords.max?.toString(),
|
||||
);
|
||||
if (state.numWords <= (constraints.numWords.recommendation ?? 0)) {
|
||||
boundariesHint += this.i18nService.t(
|
||||
"passphraseNumWordsRecommendationHint",
|
||||
constraints.numWords.recommendation?.toString(),
|
||||
);
|
||||
}
|
||||
this.numWordsBoundariesHint.next(boundariesHint);
|
||||
});
|
||||
|
||||
// the first emission is the current value; subsequent emissions are updates
|
||||
settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated);
|
||||
@@ -99,13 +114,6 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.toggleEnabled(Controls.capitalize, !constraints.capitalize?.readonly);
|
||||
this.toggleEnabled(Controls.includeNumber, !constraints.includeNumber?.readonly);
|
||||
|
||||
const boundariesHint = this.i18nService.t(
|
||||
"generatorBoundariesHint",
|
||||
constraints.numWords.min?.toString(),
|
||||
constraints.numWords.max?.toString(),
|
||||
);
|
||||
this.numWordsBoundariesHint.next(boundariesHint);
|
||||
});
|
||||
|
||||
// now that outputs are set up, connect inputs
|
||||
|
||||
@@ -112,20 +112,33 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
|
||||
const settings = await this.generatorService.settings(Generators.password, { singleUserId$ });
|
||||
|
||||
// bind settings to the UI
|
||||
settings
|
||||
settings.withConstraints$
|
||||
.pipe(
|
||||
map((settings) => {
|
||||
map(({ state, constraints }) => {
|
||||
// interface is "avoid" while storage is "include"
|
||||
const s: any = { ...settings };
|
||||
const s: any = { ...state };
|
||||
s.avoidAmbiguous = !s.ambiguous;
|
||||
delete s.ambiguous;
|
||||
return s;
|
||||
return [s, constraints] as const;
|
||||
}),
|
||||
takeUntil(this.destroyed$),
|
||||
)
|
||||
.subscribe((s) => {
|
||||
.subscribe(([state, constraints]) => {
|
||||
let boundariesHint = this.i18nService.t(
|
||||
"spinboxBoundariesHint",
|
||||
constraints.length.min?.toString(),
|
||||
constraints.length.max?.toString(),
|
||||
);
|
||||
if (state.length <= (constraints.length.recommendation ?? 0)) {
|
||||
boundariesHint += this.i18nService.t(
|
||||
"passwordLengthRecommendationHint",
|
||||
constraints.length.recommendation?.toString(),
|
||||
);
|
||||
}
|
||||
this.lengthBoundariesHint.next(boundariesHint);
|
||||
|
||||
// skips reactive event emissions to break a subscription cycle
|
||||
this.settings.patchValue(s, { emitEvent: false });
|
||||
this.settings.patchValue(state, { emitEvent: false });
|
||||
});
|
||||
|
||||
// explain policy & disable policy-overridden fields
|
||||
@@ -148,13 +161,6 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
|
||||
for (const [control, enabled] of toggles) {
|
||||
this.toggleEnabled(control, enabled);
|
||||
}
|
||||
|
||||
const boundariesHint = this.i18nService.t(
|
||||
"generatorBoundariesHint",
|
||||
constraints.length.min?.toString(),
|
||||
constraints.length.max?.toString(),
|
||||
);
|
||||
this.lengthBoundariesHint.next(boundariesHint);
|
||||
});
|
||||
|
||||
// cascade selections between checkboxes and spinboxes
|
||||
|
||||
Reference in New Issue
Block a user