mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
[Autofill] Apply locked autofill flow to logged out state (#827)
* Initial commit: apply locked auto-fill flow to log out auto-fill * Alphabetized imports * Removed unnecessary else conditional * Fix for talkback slider control (#828) * Initial commit: apply locked auto-fill flow to log out auto-fill * Alphabetized imports * Removed unnecessary else conditional * Fixed variable init order Co-authored-by: Matt Portune <59324545+mportune-bw@users.noreply.github.com>
This commit is contained in:
parent
b2abcda111
commit
1dc027cf49
7 changed files with 88 additions and 13 deletions
|
@ -304,7 +304,7 @@ namespace Bit.App
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Current.MainPage = new HomePage();
|
Current.MainPage = new HomePage(_appOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Bit.App.Utilities;
|
using Bit.App.Models;
|
||||||
|
using Bit.App.Utilities;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
@ -9,12 +10,14 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
public partial class HomePage : BaseContentPage
|
public partial class HomePage : BaseContentPage
|
||||||
{
|
{
|
||||||
|
private readonly AppOptions _appOptions;
|
||||||
private IMessagingService _messagingService;
|
private IMessagingService _messagingService;
|
||||||
|
|
||||||
public HomePage()
|
public HomePage(AppOptions appOptions = null)
|
||||||
{
|
{
|
||||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||||
_messagingService.Send("showStatusBar", false);
|
_messagingService.Send("showStatusBar", false);
|
||||||
|
_appOptions = appOptions;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logo.Source = !ThemeManager.UsingLightTheme ? "logo_white.png" : "logo.png";
|
_logo.Source = !ThemeManager.UsingLightTheme ? "logo_white.png" : "logo.png";
|
||||||
}
|
}
|
||||||
|
@ -22,7 +25,7 @@ namespace Bit.App.Pages
|
||||||
public async Task DismissRegisterPageAndLogInAsync(string email)
|
public async Task DismissRegisterPageAndLogInAsync(string email)
|
||||||
{
|
{
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
await Navigation.PushModalAsync(new NavigationPage(new LoginPage(email)));
|
await Navigation.PushModalAsync(new NavigationPage(new LoginPage(email, _appOptions)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
|
@ -35,7 +38,7 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
if (DoOnce())
|
if (DoOnce())
|
||||||
{
|
{
|
||||||
Navigation.PushModalAsync(new NavigationPage(new LoginPage()));
|
Navigation.PushModalAsync(new NavigationPage(new LoginPage(null, _appOptions)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Bit.App.Pages
|
||||||
Application.Current.MainPage = new NavigationPage(new AddEditPage(appOptions: _appOptions));
|
Application.Current.MainPage = new NavigationPage(new AddEditPage(appOptions: _appOptions));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (_appOptions.Uri != null)
|
if (_appOptions.Uri != null)
|
||||||
{
|
{
|
||||||
Application.Current.MainPage = new NavigationPage(new AutofillCiphersPage(_appOptions));
|
Application.Current.MainPage = new NavigationPage(new AutofillCiphersPage(_appOptions));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
using Bit.Core.Abstractions;
|
using Bit.App.Models;
|
||||||
|
using Bit.Core;
|
||||||
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
|
@ -8,15 +11,21 @@ namespace Bit.App.Pages
|
||||||
public partial class LoginPage : BaseContentPage
|
public partial class LoginPage : BaseContentPage
|
||||||
{
|
{
|
||||||
private readonly IMessagingService _messagingService;
|
private readonly IMessagingService _messagingService;
|
||||||
|
private readonly IStorageService _storageService;
|
||||||
private readonly LoginPageViewModel _vm;
|
private readonly LoginPageViewModel _vm;
|
||||||
|
private readonly AppOptions _appOptions;
|
||||||
|
|
||||||
public LoginPage(string email = null)
|
public LoginPage(string email = null, AppOptions appOptions = null)
|
||||||
{
|
{
|
||||||
|
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||||
_messagingService.Send("showStatusBar", true);
|
_messagingService.Send("showStatusBar", true);
|
||||||
|
_appOptions = appOptions;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_vm = BindingContext as LoginPageViewModel;
|
_vm = BindingContext as LoginPageViewModel;
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
|
_vm.StartTwoFactorAction = () => Device.BeginInvokeOnMainThread(async () => await StartTwoFactorAsync());
|
||||||
|
_vm.LoggedInAction = () => Device.BeginInvokeOnMainThread(async () => await LoggedInAsync());
|
||||||
_vm.Email = email;
|
_vm.Email = email;
|
||||||
MasterPasswordEntry = _masterPassword;
|
MasterPasswordEntry = _masterPassword;
|
||||||
if (Device.RuntimePlatform == Device.Android)
|
if (Device.RuntimePlatform == Device.Android)
|
||||||
|
@ -68,5 +77,34 @@ namespace Bit.App.Pages
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task StartTwoFactorAsync()
|
||||||
|
{
|
||||||
|
var page = new TwoFactorPage();
|
||||||
|
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoggedInAsync()
|
||||||
|
{
|
||||||
|
if (_appOptions != null)
|
||||||
|
{
|
||||||
|
if (_appOptions.FromAutofillFramework && _appOptions.SaveType.HasValue)
|
||||||
|
{
|
||||||
|
Application.Current.MainPage = new NavigationPage(new AddEditPage(appOptions: _appOptions));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_appOptions.Uri != null)
|
||||||
|
{
|
||||||
|
Application.Current.MainPage = new NavigationPage(new AutofillCiphersPage(_appOptions));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var previousPage = await _storageService.GetAsync<PreviousPageInfo>(Constants.PreviousPageKey);
|
||||||
|
if (previousPage != null)
|
||||||
|
{
|
||||||
|
await _storageService.RemoveAsync(Constants.PreviousPageKey);
|
||||||
|
}
|
||||||
|
Application.Current.MainPage = new TabsPage(_appOptions, previousPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Bit.Core;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
@ -65,6 +66,8 @@ namespace Bit.App.Pages
|
||||||
public Command TogglePasswordCommand { get; }
|
public Command TogglePasswordCommand { get; }
|
||||||
public string ShowPasswordIcon => ShowPassword ? "" : "";
|
public string ShowPasswordIcon => ShowPassword ? "" : "";
|
||||||
public bool RememberEmail { get; set; }
|
public bool RememberEmail { get; set; }
|
||||||
|
public Action StartTwoFactorAction { get; set; }
|
||||||
|
public Action LoggedInAction { get; set; }
|
||||||
|
|
||||||
public async Task InitAsync()
|
public async Task InitAsync()
|
||||||
{
|
{
|
||||||
|
@ -121,15 +124,14 @@ namespace Bit.App.Pages
|
||||||
await _deviceActionService.HideLoadingAsync();
|
await _deviceActionService.HideLoadingAsync();
|
||||||
if (response.TwoFactor)
|
if (response.TwoFactor)
|
||||||
{
|
{
|
||||||
var page = new TwoFactorPage();
|
StartTwoFactorAction?.Invoke();
|
||||||
await Page.Navigation.PushModalAsync(new NavigationPage(page));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var disableFavicon = await _storageService.GetAsync<bool?>(Constants.DisableFaviconKey);
|
var disableFavicon = await _storageService.GetAsync<bool?>(Constants.DisableFaviconKey);
|
||||||
await _stateService.SaveAsync(Constants.DisableFaviconKey, disableFavicon.GetValueOrDefault());
|
await _stateService.SaveAsync(Constants.DisableFaviconKey, disableFavicon.GetValueOrDefault());
|
||||||
var task = Task.Run(async () => await _syncService.FullSyncAsync(true));
|
var task = Task.Run(async () => await _syncService.FullSyncAsync(true));
|
||||||
Application.Current.MainPage = new TabsPage();
|
LoggedInAction?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ApiException e)
|
catch (ApiException e)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using Bit.App.Controls;
|
using Bit.App.Controls;
|
||||||
|
using Bit.App.Models;
|
||||||
|
using Bit.Core;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
@ -11,18 +13,23 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
private readonly IBroadcasterService _broadcasterService;
|
private readonly IBroadcasterService _broadcasterService;
|
||||||
private readonly IMessagingService _messagingService;
|
private readonly IMessagingService _messagingService;
|
||||||
|
private readonly IStorageService _storageService;
|
||||||
|
private readonly AppOptions _appOptions;
|
||||||
|
|
||||||
private TwoFactorPageViewModel _vm;
|
private TwoFactorPageViewModel _vm;
|
||||||
private bool _inited;
|
private bool _inited;
|
||||||
|
|
||||||
public TwoFactorPage()
|
public TwoFactorPage(AppOptions appOptions = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SetActivityIndicator();
|
SetActivityIndicator();
|
||||||
|
_appOptions = appOptions;
|
||||||
|
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||||
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
||||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||||
_vm = BindingContext as TwoFactorPageViewModel;
|
_vm = BindingContext as TwoFactorPageViewModel;
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
|
_vm.TwoFactorAction = () => Device.BeginInvokeOnMainThread(async () => await TwoFactorAuthAsync());
|
||||||
DuoWebView = _duoWebView;
|
DuoWebView = _duoWebView;
|
||||||
if (Device.RuntimePlatform == Device.Android)
|
if (Device.RuntimePlatform == Device.Android)
|
||||||
{
|
{
|
||||||
|
@ -151,5 +158,28 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task TwoFactorAuthAsync()
|
||||||
|
{
|
||||||
|
if (_appOptions != null)
|
||||||
|
{
|
||||||
|
if (_appOptions.FromAutofillFramework && _appOptions.SaveType.HasValue)
|
||||||
|
{
|
||||||
|
Application.Current.MainPage = new NavigationPage(new AddEditPage(appOptions: _appOptions));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_appOptions.Uri != null)
|
||||||
|
{
|
||||||
|
Application.Current.MainPage = new NavigationPage(new AutofillCiphersPage(_appOptions));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var previousPage = await _storageService.GetAsync<PreviousPageInfo>(Constants.PreviousPageKey);
|
||||||
|
if (previousPage != null)
|
||||||
|
{
|
||||||
|
await _storageService.RemoveAsync(Constants.PreviousPageKey);
|
||||||
|
}
|
||||||
|
Application.Current.MainPage = new TabsPage(_appOptions, previousPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using Bit.Core.Enums;
|
||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
using Bit.Core.Models.Request;
|
using Bit.Core.Models.Request;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -88,6 +89,7 @@ namespace Bit.App.Pages
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public Command SubmitCommand { get; }
|
public Command SubmitCommand { get; }
|
||||||
|
public Action TwoFactorAction { get; set; }
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
|
@ -209,7 +211,7 @@ namespace Bit.App.Pages
|
||||||
_broadcasterService.Unsubscribe(nameof(TwoFactorPage));
|
_broadcasterService.Unsubscribe(nameof(TwoFactorPage));
|
||||||
var disableFavicon = await _storageService.GetAsync<bool?>(Constants.DisableFaviconKey);
|
var disableFavicon = await _storageService.GetAsync<bool?>(Constants.DisableFaviconKey);
|
||||||
await _stateService.SaveAsync(Constants.DisableFaviconKey, disableFavicon.GetValueOrDefault());
|
await _stateService.SaveAsync(Constants.DisableFaviconKey, disableFavicon.GetValueOrDefault());
|
||||||
Application.Current.MainPage = new TabsPage();
|
TwoFactorAction?.Invoke();
|
||||||
}
|
}
|
||||||
catch (ApiException e)
|
catch (ApiException e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue