mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-24279] Utilize Policy vNext endpoint (#16317)
This commit is contained in:
@@ -24,4 +24,5 @@ export abstract class PolicyApiServiceAbstraction {
|
||||
type: PolicyType,
|
||||
request: PolicyRequest,
|
||||
) => Promise<any>;
|
||||
abstract putPolicyVNext: (organizationId: string, type: PolicyType, request: any) => Promise<any>;
|
||||
}
|
||||
|
||||
@@ -116,16 +116,32 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
}
|
||||
|
||||
async putPolicy(organizationId: string, type: PolicyType, request: PolicyRequest): Promise<any> {
|
||||
const r = await this.apiService.send(
|
||||
const response = await this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/policies/" + type,
|
||||
request,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
await this.handleResponse(response);
|
||||
}
|
||||
|
||||
async putPolicyVNext(organizationId: string, type: PolicyType, request: any): Promise<any> {
|
||||
const response = await this.apiService.send(
|
||||
"PUT",
|
||||
`/organizations/${organizationId}/policies/${type}/vnext`,
|
||||
request,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
|
||||
await this.handleResponse(response);
|
||||
}
|
||||
|
||||
private async handleResponse(response: any): Promise<void> {
|
||||
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
|
||||
const response = new PolicyResponse(r);
|
||||
const data = new PolicyData(response);
|
||||
const policyResponse = new PolicyResponse(response);
|
||||
const data = new PolicyData(policyResponse);
|
||||
await this.policyService.upsert(data, userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user