From 29951207ec52ccc02b2712f0b07fe01219d932fe Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 17 May 2019 16:36:29 -0400 Subject: [PATCH] lock page work with autofill --- src/App/App.xaml.cs | 2 +- src/App/Pages/Accounts/LockPage.xaml.cs | 26 ++++++++++++++++++--- src/App/Pages/Accounts/LockPageViewModel.cs | 4 +++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 3184a024e..ddbf86fb1 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -174,7 +174,7 @@ namespace Bit.App { if(await _lockService.IsLockedAsync()) { - Current.MainPage = new NavigationPage(new LockPage()); + Current.MainPage = new NavigationPage(new LockPage(_appOptions)); } else if(_appOptions.FromAutofillFramework && _appOptions.SaveType.HasValue) { diff --git a/src/App/Pages/Accounts/LockPage.xaml.cs b/src/App/Pages/Accounts/LockPage.xaml.cs index bd1857882..41714ec94 100644 --- a/src/App/Pages/Accounts/LockPage.xaml.cs +++ b/src/App/Pages/Accounts/LockPage.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Bit.App.Models; +using System; using System.Threading.Tasks; using Xamarin.Forms; @@ -6,13 +7,32 @@ namespace Bit.App.Pages { public partial class LockPage : BaseContentPage { - private LockPageViewModel _vm; + private readonly AppOptions _appOptions; + private readonly LockPageViewModel _vm; - public LockPage() + public LockPage(AppOptions appOptions = null) { + _appOptions = appOptions; InitializeComponent(); _vm = BindingContext as LockPageViewModel; _vm.Page = this; + _vm.UnlockedAction = () => + { + if(_appOptions != null) + { + if(_appOptions.FromAutofillFramework && _appOptions.SaveType.HasValue) + { + Application.Current.MainPage = new NavigationPage(new AddEditPage(appOptions: _appOptions)); + return; + } + else if(_appOptions.Uri != null) + { + Application.Current.MainPage = new NavigationPage(new AutofillCiphersPage(_appOptions)); + return; + } + } + Application.Current.MainPage = new TabsPage(); + }; MasterPasswordEntry = _masterPassword; PinEntry = _pin; } diff --git a/src/App/Pages/Accounts/LockPageViewModel.cs b/src/App/Pages/Accounts/LockPageViewModel.cs index cc2a7f5ac..2939ca900 100644 --- a/src/App/Pages/Accounts/LockPageViewModel.cs +++ b/src/App/Pages/Accounts/LockPageViewModel.cs @@ -1,4 +1,5 @@ using Bit.App.Abstractions; +using Bit.App.Models; using Bit.App.Resources; using Bit.Core; using Bit.Core.Abstractions; @@ -90,6 +91,7 @@ namespace Bit.App.Pages public string ShowPasswordIcon => ShowPassword ? "" : ""; public string MasterPassword { get; set; } public string Pin { get; set; } + public Action UnlockedAction { get; set; } public async Task InitAsync() { @@ -251,7 +253,7 @@ namespace Bit.App.Pages private void DoContinue() { _messagingService.Send("unlocked"); - Application.Current.MainPage = new TabsPage(); + UnlockedAction?.Invoke(); } } }