mirror of
https://github.com/bitwarden/mobile
synced 2026-02-19 02:43:29 +00:00
[PM-2287] Add trust device to master password unlock. Change trust device method. Remove email from SSO login page.
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Bit.App.Pages
|
||||
private readonly WeakEventManager<int?> _secretEntryFocusWeakEventManager = new WeakEventManager<int?>();
|
||||
private readonly IPolicyService _policyService;
|
||||
private readonly IPasswordGenerationService _passwordGenerationService;
|
||||
|
||||
private IDeviceTrustCryptoService _deviceTrustCryptoService;
|
||||
private string _email;
|
||||
private string _masterPassword;
|
||||
private string _pin;
|
||||
@@ -65,6 +65,7 @@ namespace Bit.App.Pages
|
||||
_watchDeviceService = ServiceContainer.Resolve<IWatchDeviceService>();
|
||||
_policyService = ServiceContainer.Resolve<IPolicyService>();
|
||||
_passwordGenerationService = ServiceContainer.Resolve<IPasswordGenerationService>();
|
||||
_deviceTrustCryptoService = ServiceContainer.Resolve<IDeviceTrustCryptoService>();
|
||||
|
||||
PageTitle = AppResources.VerifyMasterPassword;
|
||||
TogglePasswordCommand = new Command(TogglePassword);
|
||||
@@ -454,6 +455,11 @@ namespace Bit.App.Pages
|
||||
{
|
||||
await _cryptoService.SetKeyAsync(key);
|
||||
}
|
||||
if (await _deviceTrustCryptoService.GetUserTrustDeviceChoiceForDecryptionAsync())
|
||||
{
|
||||
await _deviceTrustCryptoService.TrustDeviceAsync();
|
||||
await _deviceTrustCryptoService.SetUserTrustDeviceChoiceForDecryptionAsync(false);
|
||||
}
|
||||
await DoContinueAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Bit.App.Pages
|
||||
private readonly LoginApproveDeviceViewModel _vm;
|
||||
private readonly AppOptions _appOptions;
|
||||
|
||||
public LoginApproveDevicePage(string email, AppOptions appOptions = null)
|
||||
public LoginApproveDevicePage(AppOptions appOptions = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
_vm = BindingContext as LoginApproveDeviceViewModel;
|
||||
@@ -24,7 +24,6 @@ namespace Bit.App.Pages
|
||||
_vm.RequestAdminApprovalAction = () => RequestAdminApprovalAsync().FireAndForget();
|
||||
_vm.CloseAction = () => { Navigation.PopModalAsync(); };
|
||||
_vm.Page = this;
|
||||
_vm.Email = email;
|
||||
_appOptions = appOptions;
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ namespace Bit.App.Pages
|
||||
|
||||
private async Task StartLogInWithMasterPassword()
|
||||
{
|
||||
var page = new TwoFactorPage(false, _appOptions);
|
||||
var page = new LockPage(_appOptions);
|
||||
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
try
|
||||
{
|
||||
Email = await _stateService.GetRememberedEmailAsync();
|
||||
var decryptOptions = await _stateService.GetAccountDecryptionOptions();
|
||||
RequestAdminApprovalEnabled = decryptOptions != null && decryptOptions.TrustedDeviceOption != null && decryptOptions.TrustedDeviceOption.HasAdminApproval;
|
||||
ApproveWithMasterPasswordEnabled = decryptOptions != null && decryptOptions.HasMasterPassword;
|
||||
|
||||
@@ -237,7 +237,11 @@ namespace Bit.App.Pages
|
||||
else
|
||||
{
|
||||
_syncService.FullSyncAsync(true).FireAndForget();
|
||||
await _deviceTrustCryptoService.TrustDeviceAsync();
|
||||
if (await _deviceTrustCryptoService.GetUserTrustDeviceChoiceForDecryptionAsync())
|
||||
{
|
||||
await _deviceTrustCryptoService.TrustDeviceAsync();
|
||||
await _deviceTrustCryptoService.SetUserTrustDeviceChoiceForDecryptionAsync(false);
|
||||
}
|
||||
LogInSuccessAction?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Bit.App.Pages
|
||||
await AppHelpers.ClearPreviousPage();
|
||||
|
||||
// Just for testing the screen
|
||||
Application.Current.MainPage = new NavigationPage(new LoginApproveDevicePage(_vm.Email, _appOptions));
|
||||
Application.Current.MainPage = new NavigationPage(new LoginApproveDevicePage(_appOptions));
|
||||
return;
|
||||
|
||||
if (await _vaultTimeoutService.IsLockedAsync())
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace Bit.App.Pages
|
||||
private readonly IOrganizationService _organizationService;
|
||||
|
||||
private string _orgIdentifier;
|
||||
private string _email;
|
||||
|
||||
public LoginSsoPageViewModel()
|
||||
{
|
||||
@@ -58,12 +57,6 @@ namespace Bit.App.Pages
|
||||
set => SetProperty(ref _orgIdentifier, value);
|
||||
}
|
||||
|
||||
public string Email
|
||||
{
|
||||
get => _email;
|
||||
set => SetProperty(ref _email, value);
|
||||
}
|
||||
|
||||
public ICommand LogInCommand { get; }
|
||||
public Action StartTwoFactorAction { get; set; }
|
||||
public Action StartSetPasswordAction { get; set; }
|
||||
@@ -84,8 +77,6 @@ namespace Bit.App.Pages
|
||||
{
|
||||
OrgIdentifier = await _stateService.GetRememberedOrgIdentifierAsync();
|
||||
}
|
||||
|
||||
Email = await _stateService.GetRememberedEmailAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -43,11 +43,6 @@ namespace Bit.Core.Services
|
||||
|
||||
public async Task<DeviceResponse> TrustDeviceAsync()
|
||||
{
|
||||
if (!await GetUserTrustDeviceChoiceForDecryptionAsync())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Attempt to get user key
|
||||
var userKey = await _cryptoService.GetEncKeyAsync();
|
||||
if (userKey == null)
|
||||
|
||||
@@ -1300,12 +1300,12 @@ namespace Bit.Core.Services
|
||||
|
||||
public async Task<bool> GetUserTrustDeviceChoiceForDecryptionAsync()
|
||||
{
|
||||
return await _storageMediatorService.GetAsync<bool>(Constants.RememberDeviceTde, true);
|
||||
return await _storageMediatorService.GetAsync<bool>(Constants.RememberDeviceTde);
|
||||
}
|
||||
|
||||
public async Task SetUserTrustDeviceChoiceForDecryptionAsync(bool value)
|
||||
{
|
||||
await _storageMediatorService.SaveAsync(Constants.RememberDeviceTde, true);
|
||||
await _storageMediatorService.SaveAsync(Constants.RememberDeviceTde, value);
|
||||
}
|
||||
|
||||
public ConfigResponse GetConfigs()
|
||||
|
||||
Reference in New Issue
Block a user