1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 10:43:35 +00:00
Files
browser/apps/web/src/app/admin-console/organizations/manage/user-confirm.component.ts
Oscar Hinton 6fd521f5e0 Migrate AC owned loose components to standalone (#15792)
Migrate AC owned loose components to standalone.
2025-08-19 14:34:12 +02:00

81 lines
2.3 KiB
TypeScript

// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Component, Inject, OnInit } from "@angular/core";
import { FormControl, FormGroup } from "@angular/forms";
import { OrganizationManagementPreferencesService } from "@bitwarden/common/admin-console/abstractions/organization-management-preferences/organization-management-preferences.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { DIALOG_DATA, DialogConfig, DialogRef, DialogService } from "@bitwarden/components";
import { KeyService } from "@bitwarden/key-management";
import { SharedModule } from "../../../shared";
export type UserConfirmDialogData = {
name: string;
userId: string;
publicKey: Uint8Array;
confirmUser: (publicKey: Uint8Array) => Promise<void>;
};
@Component({
templateUrl: "user-confirm.component.html",
imports: [SharedModule],
})
export class UserConfirmComponent implements OnInit {
name: string;
userId: string;
publicKey: Uint8Array;
loading = true;
fingerprint: string;
formPromise: Promise<any>;
formGroup = new FormGroup({
dontAskAgain: new FormControl(false),
});
constructor(
@Inject(DIALOG_DATA) protected data: UserConfirmDialogData,
private dialogRef: DialogRef,
private keyService: KeyService,
private logService: LogService,
private organizationManagementPreferencesService: OrganizationManagementPreferencesService,
) {
this.name = data.name;
this.userId = data.userId;
this.publicKey = data.publicKey;
}
async ngOnInit() {
try {
if (this.publicKey != null) {
const fingerprint = await this.keyService.getFingerprint(this.userId, this.publicKey);
if (fingerprint != null) {
this.fingerprint = fingerprint.join("-");
}
}
} catch (e) {
this.logService.error(e);
}
this.loading = false;
}
submit = async () => {
if (this.loading) {
return;
}
if (this.formGroup.value.dontAskAgain) {
await this.organizationManagementPreferencesService.autoConfirmFingerPrints.set(true);
}
await this.data.confirmUser(this.publicKey);
this.dialogRef.close();
};
static open(dialogService: DialogService, config: DialogConfig<UserConfirmDialogData>) {
return dialogService.open(UserConfirmComponent, config);
}
}