mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
* [AC-1070] Add EnforceOnLogin property to MasterPasswordPolicyOptions
* [AC-1070] Add MasterPasswordPolicy property to Identity responses
* [AC-1070] Add policy service dependency to auth service
* [AC-1070] Introduce logic to evaluate master password after successful login
* [AC-1070] Add optional ForcePasswordResetReason to profile / state service
* [AC-1070] Save ForcePasswordResetReason to state when a weak master password is found during login
- Additionally, save the AdminForcePasswordReset reason if the identity result indicates an admin password reset is in effect.
* [AC-1070] Check for a saved ForcePasswordReset reason on TabsPage load force show the update password page
* [AC-1070] Make InitAsync virtual
Allow the UpdateTempPasswordPage to override the InitAsync method to check for a reset password reason in the state service
* [AC-1070] Modify UpdateTempPassword page appearance
- Load the force password reset reason from the state service
- Make warning text dynamic based on force password reason
- Conditionally show the Current master password field if updating a weak master password
* [AC-1070] Add update password method to Api service
* [AC-1070] Introduce logic to update both temp and regular passwords
- Check the Reason to use the appropriate request/endpoint when submitting.
- Verify the users current password locally using the user verification service.
* [AC-1070] Introduce VerifyMasterPasswordResponse
* [AC-1070] Add logic to evaluate master password on unlock
* [AC-1070] Add support 2FA login flow
Keep track of the reset password reason after a password login requires 2FA. During 2FA submission, check if there is a saved reason, and if so, force the user to update their password.
* [AC-1070] Formatting
* [AC-1070] Remove string key from service resolution
* [AC-1070] Change master password options to method variable to avoid class field
Add null check for password strength result and log an error as this is an unexpected flow
* [AC-1070] Remove usage of i18nService
* [AC-1070] Use AsyncCommand for SubmitCommand
* [AC-1070] Remove type from ShowToast call
* [AC-1070] Simplify UpdatePassword methods to accept string for the new encryption key
* [AC-1070] Use full text for key for the CurrentMasterPassword resource
* [AC-1070] Convert Reason to a private class field
* [AC-1070] Formatting changes
* [AC-1070] Simplify if statements in master password options policy service method
* [AC-1070] Use the saved force password reset reason after 2FA login
* [AC-1070] Use constant for ForceUpdatePassword message command
* [AC-1070] Move shared RequirePasswordChangeOnLogin method into PolicyService
* Revert "[AC-1070] Move shared RequirePasswordChangeOnLogin method into PolicyService"
This reverts commit e4feac130f.
* [AC-1070] Add check for null password strength response
* [AC-1070] Fix broken show password icon
* [AC-1070] Add show password icon for current master password
179 lines
6.1 KiB
C#
179 lines
6.1 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Bit.App.Effects;
|
|
using Bit.App.Models;
|
|
using Bit.App.Resources;
|
|
using Bit.Core;
|
|
using Bit.Core.Abstractions;
|
|
using Bit.Core.Models.Data;
|
|
using Bit.Core.Utilities;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Bit.App.Pages
|
|
{
|
|
public class TabsPage : TabbedPage
|
|
{
|
|
private readonly IBroadcasterService _broadcasterService;
|
|
private readonly IMessagingService _messagingService;
|
|
private readonly IKeyConnectorService _keyConnectorService;
|
|
private readonly IStateService _stateService;
|
|
private readonly LazyResolve<ILogger> _logger = new LazyResolve<ILogger>("logger");
|
|
|
|
private NavigationPage _groupingsPage;
|
|
private NavigationPage _sendGroupingsPage;
|
|
private NavigationPage _generatorPage;
|
|
|
|
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null)
|
|
{
|
|
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
|
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
|
_keyConnectorService = ServiceContainer.Resolve<IKeyConnectorService>("keyConnectorService");
|
|
_stateService = ServiceContainer.Resolve<IStateService>();
|
|
|
|
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
|
|
{
|
|
Title = AppResources.MyVault,
|
|
IconImageSource = "lock.png"
|
|
};
|
|
Children.Add(_groupingsPage);
|
|
|
|
_sendGroupingsPage = new NavigationPage(new SendGroupingsPage(true, null, null, appOptions))
|
|
{
|
|
Title = AppResources.Send,
|
|
IconImageSource = "send.png",
|
|
};
|
|
Children.Add(_sendGroupingsPage);
|
|
|
|
_generatorPage = new NavigationPage(new GeneratorPage(true, null, this))
|
|
{
|
|
Title = AppResources.Generator,
|
|
IconImageSource = "generate.png"
|
|
};
|
|
Children.Add(_generatorPage);
|
|
|
|
var settingsPage = new NavigationPage(new SettingsPage(this))
|
|
{
|
|
Title = AppResources.Settings,
|
|
IconImageSource = "cog_settings.png"
|
|
};
|
|
Children.Add(settingsPage);
|
|
|
|
if (Device.RuntimePlatform == Device.Android)
|
|
{
|
|
Effects.Add(new TabBarEffect());
|
|
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetToolbarPlacement(this,
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement.Bottom);
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false);
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSmoothScrollEnabled(this, false);
|
|
}
|
|
|
|
if (appOptions?.GeneratorTile ?? false)
|
|
{
|
|
appOptions.GeneratorTile = false;
|
|
ResetToGeneratorPage();
|
|
}
|
|
else if (appOptions?.MyVaultTile ?? false)
|
|
{
|
|
appOptions.MyVaultTile = false;
|
|
}
|
|
else if (appOptions?.CreateSend != null)
|
|
{
|
|
ResetToSendPage();
|
|
}
|
|
}
|
|
|
|
protected override async void OnAppearing()
|
|
{
|
|
base.OnAppearing();
|
|
_broadcasterService.Subscribe(nameof(TabsPage), async (message) =>
|
|
{
|
|
if (message.Command == "syncCompleted")
|
|
{
|
|
Device.BeginInvokeOnMainThread(async () => await UpdateVaultButtonTitleAsync());
|
|
}
|
|
});
|
|
await UpdateVaultButtonTitleAsync();
|
|
if (await _keyConnectorService.UserNeedsMigration())
|
|
{
|
|
_messagingService.Send("convertAccountToKeyConnector");
|
|
}
|
|
|
|
var forcePasswordResetReason = await _stateService.GetForcePasswordResetReasonAsync();
|
|
|
|
if (forcePasswordResetReason.HasValue)
|
|
{
|
|
_messagingService.Send(Constants.ForceUpdatePassword);
|
|
}
|
|
}
|
|
|
|
protected override void OnDisappearing()
|
|
{
|
|
base.OnDisappearing();
|
|
_broadcasterService.Unsubscribe(nameof(TabsPage));
|
|
}
|
|
|
|
public void ResetToVaultPage()
|
|
{
|
|
CurrentPage = _groupingsPage;
|
|
}
|
|
|
|
public void ResetToGeneratorPage()
|
|
{
|
|
CurrentPage = _generatorPage;
|
|
}
|
|
|
|
public void ResetToSendPage()
|
|
{
|
|
CurrentPage = _sendGroupingsPage;
|
|
}
|
|
|
|
protected async override void OnCurrentPageChanged()
|
|
{
|
|
if (CurrentPage is NavigationPage navPage)
|
|
{
|
|
if (_groupingsPage?.RootPage is GroupingsPage groupingsPage)
|
|
{
|
|
await groupingsPage.HideAccountSwitchingOverlayAsync();
|
|
}
|
|
|
|
_messagingService.Send("updatedTheme");
|
|
if (navPage.RootPage is GroupingsPage)
|
|
{
|
|
// Load something?
|
|
}
|
|
else if (navPage.RootPage is GeneratorPage genPage)
|
|
{
|
|
await genPage.InitAsync();
|
|
}
|
|
else if (navPage.RootPage is SettingsPage settingsPage)
|
|
{
|
|
await settingsPage.InitAsync();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnPageReselected()
|
|
{
|
|
if (_groupingsPage?.RootPage is GroupingsPage groupingsPage)
|
|
{
|
|
groupingsPage.HideAccountSwitchingOverlayAsync().FireAndForget();
|
|
}
|
|
}
|
|
|
|
private async Task UpdateVaultButtonTitleAsync()
|
|
{
|
|
try
|
|
{
|
|
var policyService = ServiceContainer.Resolve<IPolicyService>("policyService");
|
|
var isShowingVaultFilter = await policyService.ShouldShowVaultFilterAsync();
|
|
_groupingsPage.Title = isShowingVaultFilter ? AppResources.Vaults : AppResources.MyVault;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.Value.Exception(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|