1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[AC-1045] add action to vault timeout policy (#4782)

This commit is contained in:
Jake Fink
2023-04-14 19:11:33 -04:00
committed by GitHub
parent 37230aa47f
commit fbbaf10488
23 changed files with 801 additions and 408 deletions

View File

@@ -10,6 +10,7 @@ import { PolicyResponse } from "../../models/response/policy.response";
export abstract class PolicyService {
policies$: Observable<Policy[]>;
get$: (policyType: PolicyType, policyFilter?: (policy: Policy) => boolean) => Observable<Policy>;
masterPasswordPolicyOptions$: (policies?: Policy[]) => Observable<MasterPasswordPolicyOptions>;
policyAppliesToActiveUser$: (
policyType: PolicyType,

View File

@@ -42,6 +42,28 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
.subscribe();
}
/**
* Returns the first policy found that applies to the active user
* @param policyType Policy type to search for
* @param policyFilter Additional filter to apply to the policy
*/
get$(policyType: PolicyType, policyFilter?: (policy: Policy) => boolean): Observable<Policy> {
return this.policies$.pipe(
concatMap(async (policies) => {
const userId = await this.stateService.getUserId();
const appliesToCurrentUser = await this.checkPoliciesThatApplyToUser(
policies,
policyType,
policyFilter,
userId
);
if (appliesToCurrentUser) {
return policies.find((policy) => policy.type === policyType && policy.enabled);
}
})
);
}
/**
* @deprecated Do not call this, use the policies$ observable collection
*/