Suggested changes from CR
This commit is contained in:
parent
2a6f71bd00
commit
85e327ab7d
|
@ -1,36 +0,0 @@
|
||||||
<div class="modal fade" role="dialog" aria-modal="true" aria-labelledby="confirmUserTitle">
|
|
||||||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
|
||||||
<form class="modal-content" #form (ngSubmit)="submit()">
|
|
||||||
<div class="tw-text-center bwi-3x">
|
|
||||||
<i class="bwi bwi-exclamation-triangle text-warning"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2 class="tw-text-center tw-font-semibold" id="confirmUserTitle">
|
|
||||||
{{ modalTitle | i18n }}
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="modal-body">
|
|
||||||
<div>
|
|
||||||
{{ confirmDescription | i18n }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-footer">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div [formGroup]="myGroup">
|
|
||||||
<div class="form-group">
|
|
||||||
<app-user-verification ngDefaultControl formControlName="secret" name="secret">
|
|
||||||
</app-user-verification>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary btn-submit" appBlurClick>
|
|
||||||
<span>{{ confirmButtonText | i18n }}</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">
|
|
||||||
{{ "cancel" | i18n }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { Component } from "@angular/core";
|
|
||||||
|
|
||||||
import { UserSecretPromptComponent as BaseUserSecretPrompt } from "@bitwarden/angular/components/user-secret-prompt.component";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
templateUrl: "user-secret-prompt.component.html",
|
|
||||||
})
|
|
||||||
export class UserSecretPromptComponent extends BaseUserSecretPrompt {}
|
|
|
@ -1,10 +0,0 @@
|
||||||
import { Injectable } from "@angular/core";
|
|
||||||
|
|
||||||
import { UserSecretPromptService as BaseUserSecretPrompt } from "@bitwarden/angular/services/userSecretPrompt.service";
|
|
||||||
|
|
||||||
import { UserSecretPromptComponent } from "../app/components/user-secret-prompt.component";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UserSecretPromptService extends BaseUserSecretPrompt {
|
|
||||||
component = UserSecretPromptComponent;
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
import { Directive } from "@angular/core";
|
|
||||||
import { FormBuilder, FormControl } from "@angular/forms";
|
|
||||||
|
|
||||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
||||||
import { ImportService } from "@bitwarden/common/abstractions/import.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
|
||||||
|
|
||||||
import { ModalConfig } from "../services/modal.service";
|
|
||||||
|
|
||||||
import { ModalRef } from "./modal/modal.ref";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to verify the user's secret, you can customize all of the text in the modal.
|
|
||||||
*/
|
|
||||||
@Directive()
|
|
||||||
export class UserSecretPromptComponent {
|
|
||||||
showPassword = false;
|
|
||||||
organizationId = "";
|
|
||||||
confirmDescription = "";
|
|
||||||
confirmButtonText = "";
|
|
||||||
modalTitle = "";
|
|
||||||
|
|
||||||
myGroup = this.formBuilder.group({
|
|
||||||
secret: new FormControl(),
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private modalRef: ModalRef,
|
|
||||||
private cryptoService: CryptoService,
|
|
||||||
private platformUtilsService: PlatformUtilsService,
|
|
||||||
private i18nService: I18nService,
|
|
||||||
private importService: ImportService,
|
|
||||||
protected config: ModalConfig,
|
|
||||||
protected userVerificationService: UserVerificationService,
|
|
||||||
private formBuilder: FormBuilder
|
|
||||||
) {
|
|
||||||
this.confirmDescription = config.data.confirmDescription;
|
|
||||||
this.confirmButtonText = config.data.confirmButtonText;
|
|
||||||
this.modalTitle = config.data.modalTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
togglePassword() {
|
|
||||||
this.showPassword = !this.showPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
async submit() {
|
|
||||||
const secret = this.myGroup.get("secret").value;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.userVerificationService.verifyUser(secret);
|
|
||||||
} catch (e) {
|
|
||||||
this.modalRef.close(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modalRef.close(true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
import { Injectable } from "@angular/core";
|
|
||||||
|
|
||||||
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
|
|
||||||
import { UserSecretPromptService as UserSecretPromptServiceAbstraction } from "@bitwarden/common/abstractions/userSecretPrompt.service";
|
|
||||||
|
|
||||||
import { UserSecretPromptComponent } from "../components/user-secret-prompt.component";
|
|
||||||
|
|
||||||
import { ModalService } from "./modal.service";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to verify the user's File Password for the "Import passwords using File Password" feature only.
|
|
||||||
*/
|
|
||||||
@Injectable()
|
|
||||||
export class UserSecretPromptService implements UserSecretPromptServiceAbstraction {
|
|
||||||
protected component = UserSecretPromptComponent;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private modalService: ModalService,
|
|
||||||
private keyConnectorService: KeyConnectorService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
protectedFields() {
|
|
||||||
return ["TOTP", "Password", "H_Field", "Card Number", "Security Code"];
|
|
||||||
}
|
|
||||||
|
|
||||||
async showPasswordPrompt(
|
|
||||||
confirmDescription: string,
|
|
||||||
confirmButtonText: string,
|
|
||||||
modalTitle: string
|
|
||||||
) {
|
|
||||||
if (!(await this.enabled())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ref = await this.modalService.open(this.component, {
|
|
||||||
allowMultipleModals: true,
|
|
||||||
data: {
|
|
||||||
confirmDescription: confirmDescription,
|
|
||||||
confirmButtonText: confirmButtonText,
|
|
||||||
modalTitle: modalTitle,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (ref == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (await ref.onClosedPromise()) === true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async enabled() {
|
|
||||||
return !(await this.keyConnectorService.getUsesKeyConnector());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
export abstract class UserSecretPromptService {
|
|
||||||
protectedFields: () => string[];
|
|
||||||
showPasswordPrompt: (
|
|
||||||
confirmDescription: string,
|
|
||||||
confirmButtonText: string,
|
|
||||||
modalTitle: string
|
|
||||||
) => Promise<boolean>;
|
|
||||||
enabled: () => Promise<boolean>;
|
|
||||||
}
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
export abstract class UserVerificationPromptService {
|
||||||
|
protectedFields: () => string[];
|
||||||
|
showUserVerificationPrompt: (
|
||||||
|
confirmDescription?: string,
|
||||||
|
confirmButtonText?: string,
|
||||||
|
modalTitle?: string
|
||||||
|
) => Promise<boolean>;
|
||||||
|
enabled: () => Promise<boolean>;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum EncryptedExportType {
|
||||||
|
AccountEncrypted = 0,
|
||||||
|
FileEncrypted = 1,
|
||||||
|
}
|
Loading…
Reference in New Issue