mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
[PM-5465] Fix null checks in login view uris (#7421)
* Prefer empty lists to null * Defensively null check public properties
This commit is contained in:
parent
48d4c88770
commit
f8d72f0231
@ -330,7 +330,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
|
||||
this.cipher.login.uris.length === 1 &&
|
||||
(this.cipher.login.uris[0].uri == null || this.cipher.login.uris[0].uri === "")
|
||||
) {
|
||||
this.cipher.login.uris = null;
|
||||
this.cipher.login.uris = [];
|
||||
}
|
||||
|
||||
// Allows saving of selected collections during "Add" and "Clone" flows
|
||||
|
@ -46,7 +46,13 @@ export class CipherRequest {
|
||||
switch (this.type) {
|
||||
case CipherType.Login:
|
||||
this.login = new LoginApi();
|
||||
this.login.uris = null;
|
||||
this.login.uris =
|
||||
cipher.login.uris?.map((u) => {
|
||||
const uri = new LoginUriApi();
|
||||
uri.uri = u.uri != null ? u.uri.encryptedString : null;
|
||||
uri.match = u.match != null ? u.match : null;
|
||||
return uri;
|
||||
}) ?? [];
|
||||
this.login.username = cipher.login.username ? cipher.login.username.encryptedString : null;
|
||||
this.login.password = cipher.login.password ? cipher.login.password.encryptedString : null;
|
||||
this.login.passwordRevisionDate =
|
||||
@ -56,15 +62,6 @@ export class CipherRequest {
|
||||
this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null;
|
||||
this.login.autofillOnPageLoad = cipher.login.autofillOnPageLoad;
|
||||
|
||||
if (cipher.login.uris != null) {
|
||||
this.login.uris = cipher.login.uris.map((u) => {
|
||||
const uri = new LoginUriApi();
|
||||
uri.uri = u.uri != null ? u.uri.encryptedString : null;
|
||||
uri.match = u.match != null ? u.match : null;
|
||||
return uri;
|
||||
});
|
||||
}
|
||||
|
||||
if (cipher.login.fido2Credentials != null) {
|
||||
this.login.fido2Credentials = cipher.login.fido2Credentials.map((key) => {
|
||||
const keyApi = new Fido2CredentialApi();
|
||||
|
@ -61,7 +61,7 @@ export class LoginView extends ItemView {
|
||||
}
|
||||
|
||||
get hasUris(): boolean {
|
||||
return this.uris.length > 0;
|
||||
return this.uris != null && this.uris.length > 0;
|
||||
}
|
||||
|
||||
get hasFido2Credentials(): boolean {
|
||||
|
Loading…
Reference in New Issue
Block a user