config flow

This commit is contained in:
kspearrin 2018-09-21 14:29:42 -04:00
parent 471871eb2e
commit eee96bf8cf
3 changed files with 48 additions and 6 deletions

View file

@ -143,16 +143,48 @@ namespace Bit.iOS.Autofill
public override void PrepareInterfaceForExtensionConfiguration() public override void PrepareInterfaceForExtensionConfiguration()
{ {
System.Diagnostics.Debug.WriteLine("AUTOFILL BITWARDEN: PrepareInterfaceForExtensionConfiguration");
_context.Configuring = true;
var authService = Resolver.Resolve<IAuthService>(); var authService = Resolver.Resolve<IAuthService>();
if(authService.IsAuthenticated) if (!authService.IsAuthenticated)
{ {
var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve<ICipherService>()); var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainApp, AppResources.Ok, (a) =>
{
ExtensionContext.CompleteExtensionConfigurationRequest();
});
PresentViewController(alert, true, null);
return;
}
var lockService = Resolver.Resolve<ILockService>();
var lockType = lockService.GetLockTypeAsync(false).GetAwaiter().GetResult();
switch (lockType)
{
case App.Enums.LockType.Fingerprint:
PerformSegue("lockFingerprintSegue", this);
break;
case App.Enums.LockType.PIN:
PerformSegue("lockPinSegue", this);
break;
case App.Enums.LockType.Password:
PerformSegue("lockPasswordSegue", this);
break;
default:
var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve<ICipherService>());
ExtensionContext.CompleteExtensionConfigurationRequest();
break;
} }
ExtensionContext.CompleteExtensionConfigurationRequest();
} }
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)
{
ExtensionContext.CompleteExtensionConfigurationRequest();
return;
}
if(string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(password)) if(string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(password))
{ {
_googleAnalyticsService.TrackAutofillExtensionEvent("Canceled"); _googleAnalyticsService.TrackAutofillExtensionEvent("Canceled");
@ -223,6 +255,12 @@ namespace Bit.iOS.Autofill
ProvideCredential(); ProvideCredential();
return; return;
} }
if(_context.Configuring)
{
var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve<ICipherService>());
ExtensionContext.CompleteExtensionConfigurationRequest();
return;
}
PerformSegue("loginListSegue", this); PerformSegue("loginListSegue", this);
}); });
} }

View file

@ -22,8 +22,11 @@
<string>MainInterface</string> <string>MainInterface</string>
<key>NSExtensionPointIdentifier</key> <key>NSExtensionPointIdentifier</key>
<string>com.apple.authentication-services-credential-provider-ui</string> <string>com.apple.authentication-services-credential-provider-ui</string>
<key>ASCredentialProviderExtensionShowsConfigurationUI</key> <key>NSExtensionAttributes</key>
<true/> <dict>
<key>ASCredentialProviderExtensionShowsConfigurationUI</key>
<true/>
</dict>
</dict> </dict>
<key>UIDeviceFamily</key> <key>UIDeviceFamily</key>
<array> <array>

View file

@ -8,6 +8,7 @@ namespace Bit.iOS.Autofill.Models
{ {
public NSExtensionContext ExtContext { get; set; } public NSExtensionContext ExtContext { get; set; }
public ASCredentialServiceIdentifier[] ServiceIdentifiers { get; set; } public ASCredentialServiceIdentifier[] ServiceIdentifiers { get; set; }
public ASPasswordCredentialIdentity CredentialIdentity { get; set; } public ASPasswordCredentialIdentity CredentialIdentity { get; set; }
public bool Configuring { get; set; }
} }
} }