mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 07:43:37 +00:00
[SG-995] Remove automatic navigation from Home to Login if remembered (#2335)
This commit is contained in:
@@ -459,14 +459,7 @@ namespace Bit.App
|
|||||||
switch (navTarget)
|
switch (navTarget)
|
||||||
{
|
{
|
||||||
case NavigationTarget.HomeLogin:
|
case NavigationTarget.HomeLogin:
|
||||||
if (navParams is HomeNavigationParams homeParams)
|
|
||||||
{
|
|
||||||
Current.MainPage = new NavigationPage(new HomePage(Options, homeParams.ShouldCheckRememberEmail));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Current.MainPage = new NavigationPage(new HomePage(Options));
|
Current.MainPage = new NavigationPage(new HomePage(Options));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NavigationTarget.Login:
|
case NavigationTarget.Login:
|
||||||
if (navParams is LoginNavigationParams loginParams)
|
if (navParams is LoginNavigationParams loginParams)
|
||||||
|
|||||||
@@ -15,14 +15,13 @@ namespace Bit.App.Pages
|
|||||||
private readonly AppOptions _appOptions;
|
private readonly AppOptions _appOptions;
|
||||||
private IBroadcasterService _broadcasterService;
|
private IBroadcasterService _broadcasterService;
|
||||||
|
|
||||||
public HomePage(AppOptions appOptions = null, bool shouldCheckRememberEmail = true)
|
public HomePage(AppOptions appOptions = null)
|
||||||
{
|
{
|
||||||
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
||||||
_appOptions = appOptions;
|
_appOptions = appOptions;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_vm = BindingContext as HomeViewModel;
|
_vm = BindingContext as HomeViewModel;
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
_vm.ShouldCheckRememberEmail = shouldCheckRememberEmail;
|
|
||||||
_vm.ShowCancelButton = _appOptions?.IosExtension ?? false;
|
_vm.ShowCancelButton = _appOptions?.IosExtension ?? false;
|
||||||
_vm.StartLoginAction = async () => await StartLoginAsync();
|
_vm.StartLoginAction = async () => await StartLoginAsync();
|
||||||
_vm.StartRegisterAction = () => Device.BeginInvokeOnMainThread(async () => await StartRegisterAsync());
|
_vm.StartRegisterAction = () => Device.BeginInvokeOnMainThread(async () => await StartRegisterAsync());
|
||||||
@@ -71,8 +70,6 @@ namespace Bit.App.Pages
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_vm.CheckNavigateLoginStep();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnBackButtonPressed()
|
protected override bool OnBackButtonPressed()
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
public bool CanContinue => !string.IsNullOrEmpty(Email);
|
public bool CanContinue => !string.IsNullOrEmpty(Email);
|
||||||
|
|
||||||
public bool ShouldCheckRememberEmail { get; set; }
|
|
||||||
|
|
||||||
public FormattedString CreateAccountText
|
public FormattedString CreateAccountText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -110,15 +108,6 @@ namespace Bit.App.Pages
|
|||||||
RememberEmail = !string.IsNullOrEmpty(Email);
|
RememberEmail = !string.IsNullOrEmpty(Email);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckNavigateLoginStep()
|
|
||||||
{
|
|
||||||
if (ShouldCheckRememberEmail && RememberEmail)
|
|
||||||
{
|
|
||||||
StartLoginAction();
|
|
||||||
}
|
|
||||||
ShouldCheckRememberEmail = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ContinueToLoginStepAsync()
|
public async Task ContinueToLoginStepAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -109,11 +109,11 @@ namespace Bit.App.Utilities.AccountManagement
|
|||||||
|
|
||||||
var email = await _stateService.GetEmailAsync();
|
var email = await _stateService.GetEmailAsync();
|
||||||
await _stateService.SetRememberedEmailAsync(email);
|
await _stateService.SetRememberedEmailAsync(email);
|
||||||
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin, new HomeNavigationParams(true));
|
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin, new HomeNavigationParams(false));
|
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ namespace Bit.App.Utilities.AccountManagement
|
|||||||
await Device.InvokeOnMainThreadAsync(() =>
|
await Device.InvokeOnMainThreadAsync(() =>
|
||||||
{
|
{
|
||||||
Options.HideAccountSwitcher = false;
|
Options.HideAccountSwitcher = false;
|
||||||
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin, new HomeNavigationParams(false));
|
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
using Bit.App.Abstractions;
|
|
||||||
|
|
||||||
namespace Bit.App.Utilities.AccountManagement
|
|
||||||
{
|
|
||||||
public class HomeNavigationParams : INavigationParams
|
|
||||||
{
|
|
||||||
public HomeNavigationParams(bool shouldCheckRememberEmail)
|
|
||||||
{
|
|
||||||
ShouldCheckRememberEmail = shouldCheckRememberEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShouldCheckRememberEmail { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -426,10 +426,10 @@ namespace Bit.iOS.Autofill
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchHomePage(bool shouldCheckRememberEmail = true)
|
private void LaunchHomePage()
|
||||||
{
|
{
|
||||||
var appOptions = new AppOptions { IosExtension = true };
|
var appOptions = new AppOptions { IosExtension = true };
|
||||||
var homePage = new HomePage(appOptions, shouldCheckRememberEmail);
|
var homePage = new HomePage(appOptions);
|
||||||
var app = new App.App(appOptions);
|
var app = new App.App(appOptions);
|
||||||
ThemeManager.SetTheme(app.Resources);
|
ThemeManager.SetTheme(app.Resources);
|
||||||
ThemeManager.ApplyResourcesTo(homePage);
|
ThemeManager.ApplyResourcesTo(homePage);
|
||||||
@@ -458,8 +458,8 @@ namespace Bit.iOS.Autofill
|
|||||||
ThemeManager.ApplyResourcesTo(environmentPage);
|
ThemeManager.ApplyResourcesTo(environmentPage);
|
||||||
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPage(environmentPage);
|
var navigationPage = new NavigationPage(environmentPage);
|
||||||
@@ -477,7 +477,7 @@ namespace Bit.iOS.Autofill
|
|||||||
if (registerPage.BindingContext is RegisterPageViewModel vm)
|
if (registerPage.BindingContext is RegisterPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.RegistrationSuccess = () => DismissViewController(false, () => LaunchLoginFlow(vm.Email));
|
vm.RegistrationSuccess = () => DismissViewController(false, () => LaunchLoginFlow(vm.Email));
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPage(registerPage);
|
var navigationPage = new NavigationPage(registerPage);
|
||||||
@@ -500,7 +500,7 @@ namespace Bit.iOS.Autofill
|
|||||||
vm.StartSsoLoginAction = () => DismissViewController(false, () => LaunchLoginSsoFlow());
|
vm.StartSsoLoginAction = () => DismissViewController(false, () => LaunchLoginSsoFlow());
|
||||||
vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(email));
|
vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(email));
|
||||||
vm.LogInSuccessAction = () => DismissLockAndContinue();
|
vm.LogInSuccessAction = () => DismissLockAndContinue();
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPage(loginPage);
|
var navigationPage = new NavigationPage(loginPage);
|
||||||
@@ -629,14 +629,7 @@ namespace Bit.iOS.Autofill
|
|||||||
switch (navTarget)
|
switch (navTarget)
|
||||||
{
|
{
|
||||||
case NavigationTarget.HomeLogin:
|
case NavigationTarget.HomeLogin:
|
||||||
if (navParams is HomeNavigationParams homeParams)
|
|
||||||
{
|
|
||||||
DismissViewController(false, () => LaunchHomePage(homeParams.ShouldCheckRememberEmail));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DismissViewController(false, () => LaunchHomePage());
|
DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NavigationTarget.Login:
|
case NavigationTarget.Login:
|
||||||
if (navParams is LoginNavigationParams loginParams)
|
if (navParams is LoginNavigationParams loginParams)
|
||||||
|
|||||||
@@ -447,10 +447,10 @@ namespace Bit.iOS.Extension
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchHomePage(bool shouldCheckRememberEmail = true)
|
private void LaunchHomePage()
|
||||||
{
|
{
|
||||||
var appOptions = new AppOptions { IosExtension = true };
|
var appOptions = new AppOptions { IosExtension = true };
|
||||||
var homePage = new HomePage(appOptions, shouldCheckRememberEmail);
|
var homePage = new HomePage(appOptions);
|
||||||
var app = new App.App(appOptions);
|
var app = new App.App(appOptions);
|
||||||
ThemeManager.SetTheme(app.Resources);
|
ThemeManager.SetTheme(app.Resources);
|
||||||
ThemeManager.ApplyResourcesTo(homePage);
|
ThemeManager.ApplyResourcesTo(homePage);
|
||||||
@@ -479,8 +479,8 @@ namespace Bit.iOS.Extension
|
|||||||
ThemeManager.ApplyResourcesTo(environmentPage);
|
ThemeManager.ApplyResourcesTo(environmentPage);
|
||||||
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPage(environmentPage);
|
var navigationPage = new NavigationPage(environmentPage);
|
||||||
@@ -498,7 +498,7 @@ namespace Bit.iOS.Extension
|
|||||||
if (registerPage.BindingContext is RegisterPageViewModel vm)
|
if (registerPage.BindingContext is RegisterPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.RegistrationSuccess = () => DismissViewController(false, () => LaunchLoginFlow(vm.Email));
|
vm.RegistrationSuccess = () => DismissViewController(false, () => LaunchLoginFlow(vm.Email));
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPage(registerPage);
|
var navigationPage = new NavigationPage(registerPage);
|
||||||
@@ -521,7 +521,7 @@ namespace Bit.iOS.Extension
|
|||||||
vm.StartSsoLoginAction = () => DismissViewController(false, () => LaunchLoginSsoFlow());
|
vm.StartSsoLoginAction = () => DismissViewController(false, () => LaunchLoginSsoFlow());
|
||||||
vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(email));
|
vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(email));
|
||||||
vm.LogInSuccessAction = () => DismissLockAndContinue();
|
vm.LogInSuccessAction = () => DismissLockAndContinue();
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPage(loginPage);
|
var navigationPage = new NavigationPage(loginPage);
|
||||||
|
|||||||
@@ -287,9 +287,9 @@ namespace Bit.iOS.ShareExtension
|
|||||||
return _app;
|
return _app;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchHomePage(bool shouldCheckRememberEmail = true)
|
private void LaunchHomePage()
|
||||||
{
|
{
|
||||||
var homePage = new HomePage(_appOptions.Value, shouldCheckRememberEmail);
|
var homePage = new HomePage(_appOptions.Value);
|
||||||
SetupAppAndApplyResources(homePage);
|
SetupAppAndApplyResources(homePage);
|
||||||
if (homePage.BindingContext is HomeViewModel vm)
|
if (homePage.BindingContext is HomeViewModel vm)
|
||||||
{
|
{
|
||||||
@@ -311,8 +311,8 @@ namespace Bit.iOS.ShareExtension
|
|||||||
ThemeManager.ApplyResourcesTo(environmentPage);
|
ThemeManager.ApplyResourcesTo(environmentPage);
|
||||||
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SubmitSuccessAction = () => DismissAndLaunch(() => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.SubmitSuccessAction = () => DismissAndLaunch(() => LaunchHomePage());
|
||||||
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigateToPage(environmentPage);
|
NavigateToPage(environmentPage);
|
||||||
@@ -325,7 +325,7 @@ namespace Bit.iOS.ShareExtension
|
|||||||
if (registerPage.BindingContext is RegisterPageViewModel vm)
|
if (registerPage.BindingContext is RegisterPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.RegistrationSuccess = () => DismissAndLaunch(() => LaunchLoginFlow(vm.Email));
|
vm.RegistrationSuccess = () => DismissAndLaunch(() => LaunchLoginFlow(vm.Email));
|
||||||
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage());
|
||||||
}
|
}
|
||||||
NavigateToPage(registerPage);
|
NavigateToPage(registerPage);
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ namespace Bit.iOS.ShareExtension
|
|||||||
vm.StartSsoLoginAction = () => DismissAndLaunch(() => LaunchLoginSsoFlow());
|
vm.StartSsoLoginAction = () => DismissAndLaunch(() => LaunchLoginSsoFlow());
|
||||||
vm.LogInWithDeviceAction = () => DismissAndLaunch(() => LaunchLoginWithDevice(email));
|
vm.LogInWithDeviceAction = () => DismissAndLaunch(() => LaunchLoginWithDevice(email));
|
||||||
vm.LogInSuccessAction = () => { DismissLockAndContinue(); };
|
vm.LogInSuccessAction = () => { DismissLockAndContinue(); };
|
||||||
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage(shouldCheckRememberEmail: false));
|
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage());
|
||||||
}
|
}
|
||||||
NavigateToPage(loginPage);
|
NavigateToPage(loginPage);
|
||||||
|
|
||||||
@@ -441,14 +441,7 @@ namespace Bit.iOS.ShareExtension
|
|||||||
switch (navTarget)
|
switch (navTarget)
|
||||||
{
|
{
|
||||||
case NavigationTarget.HomeLogin:
|
case NavigationTarget.HomeLogin:
|
||||||
if (navParams is HomeNavigationParams homeParams)
|
|
||||||
{
|
|
||||||
ExecuteLaunch(() => LaunchHomePage(homeParams.ShouldCheckRememberEmail));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ExecuteLaunch(() => LaunchHomePage());
|
ExecuteLaunch(() => LaunchHomePage());
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NavigationTarget.Login:
|
case NavigationTarget.Login:
|
||||||
if (navParams is LoginNavigationParams loginParams)
|
if (navParams is LoginNavigationParams loginParams)
|
||||||
|
|||||||
Reference in New Issue
Block a user