mirror of
https://github.com/bitwarden/mobile
synced 2025-12-12 06:13:21 +00:00
[Auto Logout] Final review of feature (#932)
* Initial commit of LockService name refactor (#831) * [Auto-Logout] Update Service layer logic (#835) * Initial commit of service logic update * Added default value for action * Updated ToggleTokensAsync conditional * Removed unused variables, updated action conditional * Initial commit: lockOption/lock refactor app layer (#840) * [Auto-Logout] Settings Refactor - Application Layer Part 2 (#844) * Initial commit of app layer part 2 * Updated biometrics position * Reverted resource name refactor * LockOptions refactor revert * Updated method casing :: Removed VaultTimeout prefix for timeouts * Fixed dupe string resource (#854) * Updated dependency to use VaultTimeoutService (#896) * [Auto Logout] Xamarin Forms in AutoFill flow (iOS) (#902) * fix typo in PINRequireMasterPasswordRestart (#900) * initial commit for xf usage in autofill * Fixed databinding for hint button * Updated Two Factor page launch - removed unused imports * First pass at broadcast/messenger implentation for autofill * setting theme in extension using theme manager * extension app resources * App resources from main app * fix ref to twoFactorPage * apply resources to page * load empty app for sytling in extension * move ios renderers to ios core * static ref to resources and GetResourceColor helper * fix method ref * move application.current.resources refs to helper * switch login page alerts to device action dialogs * run on main thread * showDialog with device action service * abstract action sheet to device action service * add support for yubikey * add yubikey iimages to extension * support close button action * add support to action extension * remove empty lines Co-authored-by: Jonas Kittner <54631600+theendlessriver13@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> * [Auto Logout] Update lock option to be default value (#929) * Initial commit - make lock action default * Removed extra whitespace Co-authored-by: Jonas Kittner <54631600+theendlessriver13@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using AuthenticationServices;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Resources;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.iOS.Autofill.Models;
|
||||
@@ -8,7 +7,12 @@ using Bit.iOS.Core.Utilities;
|
||||
using Foundation;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Pages;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.App.Models;
|
||||
using CoreNFC;
|
||||
|
||||
namespace Bit.iOS.Autofill
|
||||
{
|
||||
@@ -16,6 +20,8 @@ namespace Bit.iOS.Autofill
|
||||
{
|
||||
private Context _context;
|
||||
private bool _initedAppCenter;
|
||||
private NFCNdefReaderSession _nfcSession = null;
|
||||
private Core.NFCReaderDelegate _nfcDelegate = null;
|
||||
|
||||
public CredentialProviderViewController(IntPtr handle)
|
||||
: base(handle)
|
||||
@@ -48,11 +54,11 @@ namespace Bit.iOS.Autofill
|
||||
}
|
||||
_context.UrlString = uri;
|
||||
}
|
||||
if (!CheckAuthed())
|
||||
if (!IsAuthed())
|
||||
{
|
||||
return;
|
||||
LaunchLoginFlow();
|
||||
}
|
||||
if (IsLocked())
|
||||
else if (IsLocked())
|
||||
{
|
||||
PerformSegue("lockPasswordSegue", this);
|
||||
}
|
||||
@@ -86,8 +92,9 @@ namespace Bit.iOS.Autofill
|
||||
public override void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
|
||||
{
|
||||
InitAppIfNeeded();
|
||||
if (!CheckAuthed())
|
||||
if (!IsAuthed())
|
||||
{
|
||||
LaunchLoginFlow();
|
||||
return;
|
||||
}
|
||||
_context.CredentialIdentity = credentialIdentity;
|
||||
@@ -98,8 +105,9 @@ namespace Bit.iOS.Autofill
|
||||
{
|
||||
InitAppIfNeeded();
|
||||
_context.Configuring = true;
|
||||
if (!CheckAuthed())
|
||||
if (!IsAuthed())
|
||||
{
|
||||
LaunchLoginFlow();
|
||||
return;
|
||||
}
|
||||
CheckLock(() => PerformSegue("setupSegue", this));
|
||||
@@ -235,24 +243,10 @@ namespace Bit.iOS.Autofill
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckAuthed()
|
||||
{
|
||||
if (!IsAuthed())
|
||||
{
|
||||
var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainAppAutofill, AppResources.Ok, (a) =>
|
||||
{
|
||||
CompleteRequest();
|
||||
});
|
||||
PresentViewController(alert, true, null);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsLocked()
|
||||
{
|
||||
var lockService = ServiceContainer.Resolve<ILockService>("lockService");
|
||||
return lockService.IsLockedAsync().GetAwaiter().GetResult();
|
||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
return vaultTimeoutService.IsLockedAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private bool IsAuthed()
|
||||
@@ -263,12 +257,16 @@ namespace Bit.iOS.Autofill
|
||||
|
||||
private void InitApp()
|
||||
{
|
||||
// Init Xamarin Forms
|
||||
Forms.Init();
|
||||
|
||||
if (ServiceContainer.RegisteredServices.Count > 0)
|
||||
{
|
||||
ServiceContainer.Reset();
|
||||
}
|
||||
iOSCoreHelpers.RegisterLocalServices();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
ServiceContainer.Init(deviceActionService.DeviceUserAgent);
|
||||
if (!_initedAppCenter)
|
||||
{
|
||||
@@ -277,6 +275,9 @@ namespace Bit.iOS.Autofill
|
||||
}
|
||||
iOSCoreHelpers.Bootstrap();
|
||||
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
|
||||
_nfcDelegate = new Core.NFCReaderDelegate((success, message) =>
|
||||
messagingService.Send("gotYubiKeyOTP", message));
|
||||
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);
|
||||
}
|
||||
|
||||
private void InitAppIfNeeded()
|
||||
@@ -286,5 +287,43 @@ namespace Bit.iOS.Autofill
|
||||
InitApp();
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchLoginFlow()
|
||||
{
|
||||
var loginPage = new LoginPage();
|
||||
var app = new App.App(new AppOptions { EmptyApp = true });
|
||||
ThemeManager.SetTheme(false, app.Resources);
|
||||
ThemeManager.ApplyResourcesToPage(loginPage);
|
||||
if (loginPage.BindingContext is LoginPageViewModel vm)
|
||||
{
|
||||
vm.StartTwoFactorAction = () => DismissViewController(false, () => LaunchTwoFactorFlow());
|
||||
vm.LoggedInAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => CompleteRequest();
|
||||
vm.HideHintButton = true;
|
||||
}
|
||||
|
||||
var navigationPage = new NavigationPage(loginPage);
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
}
|
||||
|
||||
private void LaunchTwoFactorFlow()
|
||||
{
|
||||
var twoFactorPage = new TwoFactorPage();
|
||||
var app = new App.App(new AppOptions { EmptyApp = true });
|
||||
ThemeManager.SetTheme(false, app.Resources);
|
||||
ThemeManager.ApplyResourcesToPage(twoFactorPage);
|
||||
if (twoFactorPage.BindingContext is TwoFactorPageViewModel vm)
|
||||
{
|
||||
vm.TwoFactorAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchLoginFlow());
|
||||
}
|
||||
|
||||
var navigationPage = new NavigationPage(twoFactorPage);
|
||||
var twoFactorController = navigationPage.CreateViewController();
|
||||
twoFactorController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(twoFactorController, true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user