1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +01:00

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()
{
System.Diagnostics.Debug.WriteLine("AUTOFILL BITWARDEN: PrepareInterfaceForExtensionConfiguration");
_context.Configuring = true;
var authService = Resolver.Resolve<IAuthService>();
if(authService.IsAuthenticated)
if (!authService.IsAuthenticated)
{
var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainApp, AppResources.Ok, (a) =>
{
var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve<ICipherService>());
}
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;
}
}
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))
{
_googleAnalyticsService.TrackAutofillExtensionEvent("Canceled");
@ -223,6 +255,12 @@ namespace Bit.iOS.Autofill
ProvideCredential();
return;
}
if(_context.Configuring)
{
var task = ASHelpers.ReplaceAllIdentities(Resolver.Resolve<ICipherService>());
ExtensionContext.CompleteExtensionConfigurationRequest();
return;
}
PerformSegue("loginListSegue", this);
});
}

View File

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

View File

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