mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-24 11:55:38 +01:00
null checks
This commit is contained in:
parent
b7c6b65a3d
commit
525b5fa19a
@ -141,13 +141,13 @@ namespace Bit.iOS.Autofill
|
|||||||
|
|
||||||
public void CompleteRequest(string username = null, string password = null, string totp = null)
|
public void CompleteRequest(string username = null, string password = null, string totp = null)
|
||||||
{
|
{
|
||||||
if(_context.Configuring)
|
if((_context?.Configuring ?? true) && string.IsNullOrWhiteSpace(password))
|
||||||
{
|
{
|
||||||
ExtensionContext.CompleteExtensionConfigurationRequest();
|
ExtensionContext?.CompleteExtensionConfigurationRequest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(password))
|
if(_context == null || string.IsNullOrWhiteSpace(password))
|
||||||
{
|
{
|
||||||
_googleAnalyticsService.TrackAutofillExtensionEvent("Canceled");
|
_googleAnalyticsService.TrackAutofillExtensionEvent("Canceled");
|
||||||
var err = new NSError(new NSString("ASExtensionErrorDomain"),
|
var err = new NSError(new NSString("ASExtensionErrorDomain"),
|
||||||
@ -156,7 +156,7 @@ namespace Bit.iOS.Autofill
|
|||||||
{
|
{
|
||||||
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
|
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
ExtensionContext.CancelRequest(err);
|
ExtensionContext?.CancelRequest(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -173,7 +173,7 @@ namespace Bit.iOS.Autofill
|
|||||||
{
|
{
|
||||||
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
|
NSRunLoop.Main.BeginInvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
ExtensionContext.CompleteRequest(cred, null);
|
ExtensionContext?.CompleteRequest(cred, null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ namespace Bit.iOS.Autofill
|
|||||||
PerformSegue("setupSegue", this);
|
PerformSegue("setupSegue", this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0)
|
if(_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0)
|
||||||
{
|
{
|
||||||
PerformSegue("loginSearchSegue", this);
|
PerformSegue("loginSearchSegue", this);
|
||||||
}
|
}
|
||||||
|
@ -26,21 +26,21 @@ namespace Bit.iOS.Core.Utilities
|
|||||||
}
|
}
|
||||||
if (identities.Any())
|
if (identities.Any())
|
||||||
{
|
{
|
||||||
await ASCredentialIdentityStore.SharedStore.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> IdentitiesCanIncremental()
|
public static async Task<bool> IdentitiesCanIncremental()
|
||||||
{
|
{
|
||||||
var state = await ASCredentialIdentityStore.SharedStore.GetCredentialIdentityStoreStateAsync();
|
var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync();
|
||||||
return state.Enabled && state.SupportsIncrementalUpdates;
|
return state != null && state.Enabled && state.SupportsIncrementalUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> AutofillEnabled()
|
public static async Task<bool> AutofillEnabled()
|
||||||
{
|
{
|
||||||
var state = await ASCredentialIdentityStore.SharedStore.GetCredentialIdentityStoreStateAsync();
|
var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync();
|
||||||
return state.Enabled;
|
return state != null && state.Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<ASPasswordCredentialIdentity> GetCipherIdentityAsync(string cipherId, ICipherService cipherService)
|
public static async Task<ASPasswordCredentialIdentity> GetCipherIdentityAsync(string cipherId, ICipherService cipherService)
|
||||||
|
@ -81,9 +81,9 @@ namespace Bit.iOS.Core.Views
|
|||||||
{
|
{
|
||||||
searchFilter = searchFilter.ToLower();
|
searchFilter = searchFilter.ToLower();
|
||||||
Items = _allItems
|
Items = _allItems
|
||||||
.Where(s => s.Name.ToLower().Contains(searchFilter) ||
|
.Where(s => s.Name?.ToLower().Contains(searchFilter) ?? false ||
|
||||||
(s.Username?.ToLower().Contains(searchFilter) ?? false) ||
|
(s.Username?.ToLower().Contains(searchFilter) ?? false) ||
|
||||||
(s.Uris?.FirstOrDefault()?.Uri.ToLower().Contains(searchFilter) ?? false))
|
(s.Uris?.FirstOrDefault()?.Uri?.ToLower().Contains(searchFilter) ?? false))
|
||||||
.TakeWhile(s => !ct.IsCancellationRequested)
|
.TakeWhile(s => !ct.IsCancellationRequested)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ namespace Bit.iOS
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await ASCredentialIdentityStore.SharedStore.SaveCredentialIdentitiesAsync(
|
await ASCredentialIdentityStore.SharedStore?.SaveCredentialIdentitiesAsync(
|
||||||
new ASPasswordCredentialIdentity[] { identity });
|
new ASPasswordCredentialIdentity[] { identity });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ namespace Bit.iOS
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await ASCredentialIdentityStore.SharedStore.RemoveCredentialIdentitiesAsync(
|
await ASCredentialIdentityStore.SharedStore?.RemoveCredentialIdentitiesAsync(
|
||||||
new ASPasswordCredentialIdentity[] { identity });
|
new ASPasswordCredentialIdentity[] { identity });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ namespace Bit.iOS
|
|||||||
{
|
{
|
||||||
if(_deviceInfoService.Version >= 12)
|
if(_deviceInfoService.Version >= 12)
|
||||||
{
|
{
|
||||||
await ASCredentialIdentityStore.SharedStore.RemoveAllCredentialIdentitiesAsync();
|
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user