2021-08-26 10:04:29 +02:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
|
2021-11-09 17:01:22 +01:00
|
|
|
import { KeyConnectorService } from "jslib-common/abstractions/keyConnector.service";
|
2021-08-26 10:04:29 +02:00
|
|
|
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "jslib-common/abstractions/passwordReprompt.service";
|
|
|
|
|
|
|
|
import { PasswordRepromptComponent } from "../components/password-reprompt.component";
|
2022-02-22 15:39:11 +01:00
|
|
|
|
2021-08-26 10:04:29 +02:00
|
|
|
import { ModalService } from "./modal.service";
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class PasswordRepromptService implements PasswordRepromptServiceAbstraction {
|
|
|
|
protected component = PasswordRepromptComponent;
|
|
|
|
|
2021-11-09 17:01:22 +01:00
|
|
|
constructor(
|
|
|
|
private modalService: ModalService,
|
|
|
|
private keyConnectorService: KeyConnectorService
|
|
|
|
) {}
|
2021-08-26 10:04:29 +02:00
|
|
|
|
|
|
|
protectedFields() {
|
|
|
|
return ["TOTP", "Password", "H_Field", "Card Number", "Security Code"];
|
2021-11-09 17:01:22 +01:00
|
|
|
}
|
|
|
|
|
2021-08-26 10:04:29 +02:00
|
|
|
async showPasswordPrompt() {
|
|
|
|
if (!(await this.enabled())) {
|
|
|
|
return true;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2021-08-26 10:04:29 +02:00
|
|
|
|
|
|
|
const ref = this.modalService.open(this.component, { allowMultipleModals: true });
|
|
|
|
|
|
|
|
if (ref == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-11-09 17:01:22 +01:00
|
|
|
|
2021-08-26 10:04:29 +02:00
|
|
|
const result = await ref.onClosedPromise();
|
|
|
|
return result === true;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-11-09 17:01:22 +01:00
|
|
|
async enabled() {
|
|
|
|
return !(await this.keyConnectorService.getUsesKeyConnector());
|
|
|
|
}
|
2021-08-26 10:04:29 +02:00
|
|
|
}
|