1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-06-25 10:26:02 +02:00

extension alert error when not logged in

This commit is contained in:
Kyle Spearrin 2016-07-21 21:33:27 -04:00
parent 580be02e2d
commit ac0a4c3756

View File

@ -17,6 +17,8 @@ using MobileCoreServices;
using Plugin.Settings.Abstractions;
using Plugin.Connectivity;
using Plugin.Fingerprint;
using Bit.iOS.Core.Utilities;
using Bit.App.Resources;
namespace Bit.iOS.Extension
{
@ -67,6 +69,17 @@ namespace Bit.iOS.Extension
{
base.ViewDidAppear(animated);
var authService = Resolver.Resolve<IAuthService>();
if(!authService.IsAuthenticated)
{
var alert = Dialogs.CreateAlert(null, "You must log into the main bitwarden app before you can use the extension.", AppResources.Ok, (a) =>
{
CompleteRequest();
});
PresentViewController(alert, true, null);
return;
}
var lockService = Resolver.Resolve<ILockService>();
var lockType = lockService.GetLockType(false);
switch(lockType)
@ -86,6 +99,15 @@ namespace Bit.iOS.Extension
}
}
private void CompleteRequest()
{
var resultsProvider = new NSItemProvider(null, UTType.PropertyList);
var resultsItem = new NSExtensionItem { Attachments = new NSItemProvider[] { resultsProvider } };
var returningItems = new NSExtensionItem[] { resultsItem };
ExtensionContext.CompleteRequest(returningItems, null);
}
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
{
var navController = segue.DestinationViewController as UINavigationController;
@ -332,6 +354,5 @@ namespace Bit.iOS.Extension
return default(T);
}
}
}