mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +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:
@@ -330,7 +330,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
|
|||||||
this.cipher.login.uris.length === 1 &&
|
this.cipher.login.uris.length === 1 &&
|
||||||
(this.cipher.login.uris[0].uri == null || this.cipher.login.uris[0].uri === "")
|
(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
|
// Allows saving of selected collections during "Add" and "Clone" flows
|
||||||
|
|||||||
@@ -46,7 +46,13 @@ export class CipherRequest {
|
|||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case CipherType.Login:
|
case CipherType.Login:
|
||||||
this.login = new LoginApi();
|
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.username = cipher.login.username ? cipher.login.username.encryptedString : null;
|
||||||
this.login.password = cipher.login.password ? cipher.login.password.encryptedString : null;
|
this.login.password = cipher.login.password ? cipher.login.password.encryptedString : null;
|
||||||
this.login.passwordRevisionDate =
|
this.login.passwordRevisionDate =
|
||||||
@@ -56,15 +62,6 @@ export class CipherRequest {
|
|||||||
this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null;
|
this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null;
|
||||||
this.login.autofillOnPageLoad = cipher.login.autofillOnPageLoad;
|
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) {
|
if (cipher.login.fido2Credentials != null) {
|
||||||
this.login.fido2Credentials = cipher.login.fido2Credentials.map((key) => {
|
this.login.fido2Credentials = cipher.login.fido2Credentials.map((key) => {
|
||||||
const keyApi = new Fido2CredentialApi();
|
const keyApi = new Fido2CredentialApi();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class LoginView extends ItemView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hasUris(): boolean {
|
get hasUris(): boolean {
|
||||||
return this.uris.length > 0;
|
return this.uris != null && this.uris.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasFido2Credentials(): boolean {
|
get hasFido2Credentials(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user