mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
PM-19102 Autofill new identity information in the popout (#13822)
* PM-17187 Autofill new card information in the popout * Add new identity autofill to browser extension * Add ability to save values from autoselect fields
This commit is contained in:
@@ -25,11 +25,30 @@ export type OptionalInitialValues = {
|
||||
username?: string;
|
||||
password?: string;
|
||||
name?: string;
|
||||
// Credit Card Information
|
||||
cardholderName?: string;
|
||||
number?: string;
|
||||
expMonth?: string;
|
||||
expYear?: string;
|
||||
code?: string;
|
||||
// Identity Information
|
||||
title?: string;
|
||||
firstName?: string;
|
||||
middleName?: string;
|
||||
lastName?: string;
|
||||
company?: string;
|
||||
ssn?: string;
|
||||
passportNumber?: string;
|
||||
licenseNumber?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
address1?: string;
|
||||
address2?: string;
|
||||
address3?: string;
|
||||
city?: string;
|
||||
state?: string;
|
||||
postalCode?: string;
|
||||
country?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,6 +73,10 @@ export class IdentitySectionComponent implements OnInit {
|
||||
country: [""],
|
||||
});
|
||||
|
||||
get initialValues() {
|
||||
return this.cipherFormContainer.config.initialValues;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private cipherFormContainer: CipherFormContainer,
|
||||
private formBuilder: FormBuilder,
|
||||
@@ -116,14 +120,58 @@ export class IdentitySectionComponent implements OnInit {
|
||||
const prefillCipher = this.cipherFormContainer.getInitialCipherView();
|
||||
|
||||
if (prefillCipher) {
|
||||
this.initFromExistingCipher(prefillCipher.identity);
|
||||
this.populateFormData(prefillCipher);
|
||||
} else {
|
||||
this.initNewCipher();
|
||||
this.identityForm.patchValue({
|
||||
username: this.cipherFormContainer.config.initialValues?.username || "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private initFromExistingCipher(existingIdentity: IdentityView) {
|
||||
this.identityForm.patchValue({
|
||||
firstName: this.initialValues.firstName ?? existingIdentity.firstName,
|
||||
middleName: this.initialValues.middleName ?? existingIdentity.middleName,
|
||||
lastName: this.initialValues.lastName ?? existingIdentity.lastName,
|
||||
company: this.initialValues.company ?? existingIdentity.company,
|
||||
ssn: this.initialValues.ssn ?? existingIdentity.ssn,
|
||||
passportNumber: this.initialValues.passportNumber ?? existingIdentity.passportNumber,
|
||||
licenseNumber: this.initialValues.licenseNumber ?? existingIdentity.licenseNumber,
|
||||
email: this.initialValues.email ?? existingIdentity.email,
|
||||
phone: this.initialValues.phone ?? existingIdentity.phone,
|
||||
address1: this.initialValues.address1 ?? existingIdentity.address1,
|
||||
address2: this.initialValues.address2 ?? existingIdentity.address2,
|
||||
address3: this.initialValues.address3 ?? existingIdentity.address3,
|
||||
city: this.initialValues.city ?? existingIdentity.city,
|
||||
state: this.initialValues.state ?? existingIdentity.state,
|
||||
postalCode: this.initialValues.postalCode ?? existingIdentity.postalCode,
|
||||
country: this.initialValues.country ?? existingIdentity.country,
|
||||
});
|
||||
}
|
||||
|
||||
private initNewCipher() {
|
||||
this.identityForm.patchValue({
|
||||
firstName: this.initialValues?.firstName || "",
|
||||
middleName: this.initialValues?.middleName || "",
|
||||
lastName: this.initialValues?.lastName || "",
|
||||
company: this.initialValues?.company || "",
|
||||
ssn: this.initialValues?.ssn || "",
|
||||
passportNumber: this.initialValues?.passportNumber || "",
|
||||
licenseNumber: this.initialValues?.licenseNumber || "",
|
||||
email: this.initialValues?.email || "",
|
||||
phone: this.initialValues?.phone || "",
|
||||
address1: this.initialValues?.address1 || "",
|
||||
address2: this.initialValues?.address2 || "",
|
||||
address3: this.initialValues?.address3 || "",
|
||||
city: this.initialValues?.city || "",
|
||||
state: this.initialValues?.state || "",
|
||||
postalCode: this.initialValues?.postalCode || "",
|
||||
country: this.initialValues?.country || "",
|
||||
});
|
||||
}
|
||||
|
||||
populateFormData(cipherView: CipherView) {
|
||||
const { identity } = cipherView;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user