1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

[PM-10107] evaluate the override password type policy (#10277)

This commit is contained in:
✨ Audrey ✨
2024-08-09 08:54:00 -04:00
committed by GitHub
parent 795c21a1c7
commit cbe7ae68cc
12 changed files with 84 additions and 56 deletions

View File

@@ -2,14 +2,14 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums";
// FIXME: use index.ts imports once policy abstractions and models
// implement ADR-0002
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
import { GeneratorType } from "@bitwarden/generator-core";
import { PasswordType } from "@bitwarden/generator-core";
/** Policy settings affecting password generator navigation */
export type GeneratorNavigationPolicy = {
/** The type of generator that should be shown by default when opening
* the password generator.
*/
defaultType?: GeneratorType;
overridePasswordType?: PasswordType;
};
/** Reduces a policy into an accumulator by preferring the password generator
@@ -27,13 +27,15 @@ export function preferPassword(
return acc;
}
const isOverridable = acc.defaultType !== "password" && policy.data.defaultType;
const result = isOverridable ? { ...acc, defaultType: policy.data.defaultType } : acc;
const isOverridable = acc.overridePasswordType !== "password" && policy.data.overridePasswordType;
const result = isOverridable
? { ...acc, overridePasswordType: policy.data.overridePasswordType }
: acc;
return result;
}
/** The default options for password generation policy. */
export const DisabledGeneratorNavigationPolicy: GeneratorNavigationPolicy = Object.freeze({
defaultType: undefined,
overridePasswordType: null,
});