1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-28 22:23:14 +00:00

Merge branch 'master' into AccountService

This commit is contained in:
addison
2021-11-16 13:32:16 -05:00
11 changed files with 68 additions and 56 deletions

View File

@@ -118,7 +118,7 @@ export class AddEditCustomFieldsComponent implements OnChanges {
}
this.cipher.fields
.filter(f => f.type = FieldType.Linked)
.filter(f => f.type === FieldType.Linked)
.forEach(f => f.linkedId = this.linkedFieldOptions[0].value);
}
}

View File

@@ -69,7 +69,10 @@ export class ExportComponent implements OnInit {
}
const secret = this.exportForm.get('secret').value;
if (!await this.userVerificationService.verifyUser(secret)) {
try {
await this.userVerificationService.verifyUser(secret);
} catch (e) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), e.message);
return;
}

View File

@@ -8,8 +8,8 @@ import {
NG_VALUE_ACCESSOR,
} from '@angular/forms';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { KeyConnectorService } from 'jslib-common/abstractions/keyConnector.service';
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
import { VerificationType } from 'jslib-common/enums/verificationType';
@@ -34,27 +34,20 @@ export class VerifyMasterPasswordComponent implements ControlValueAccessor, OnIn
private onChange: (value: Verification) => void;
constructor(private keyConnectorService: KeyConnectorService, private apiService: ApiService) { }
constructor(private keyConnectorService: KeyConnectorService,
private userVerificationService: UserVerificationService) { }
async ngOnInit() {
this.usesKeyConnector = await this.keyConnectorService.getUsesKeyConnector();
this.processChanges(this.secret.value);
this.secret.valueChanges.subscribe(secret => {
if (this.onChange == null) {
return;
}
this.onChange({
type: this.usesKeyConnector ? VerificationType.OTP : VerificationType.MasterPassword,
secret: secret,
});
});
this.secret.valueChanges.subscribe(secret => this.processChanges(secret));
}
async requestOTP() {
if (this.usesKeyConnector) {
this.disableRequestOTP = true;
await this.apiService.postAccountRequestOTP();
await this.userVerificationService.requestOTP();
}
}
@@ -78,4 +71,15 @@ export class VerifyMasterPasswordComponent implements ControlValueAccessor, OnIn
this.secret.enable();
}
}
private processChanges(secret: string) {
if (this.onChange == null) {
return;
}
this.onChange({
type: this.usesKeyConnector ? VerificationType.OTP : VerificationType.MasterPassword,
secret: secret,
});
}
}