mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00: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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user