Browse Source

[PM-2287] Add trust device to master password unlock. Change trust device method. Remove email from SSO login page.

feature/pm-2287-mp-approval
André Bispo 2 years ago
parent
commit
2014d7f562
No known key found for this signature in database
GPG Key ID: E5610EF043C76548
  1. 8
      src/App/Pages/Accounts/LockPageViewModel.cs
  2. 5
      src/App/Pages/Accounts/LoginApproveDevicePage.xaml.cs
  3. 1
      src/App/Pages/Accounts/LoginApproveDeviceViewModel.cs
  4. 6
      src/App/Pages/Accounts/LoginPasswordlessRequestViewModel.cs
  5. 2
      src/App/Pages/Accounts/LoginSsoPage.xaml.cs
  6. 9
      src/App/Pages/Accounts/LoginSsoPageViewModel.cs
  7. 5
      src/Core/Services/DeviceTrustCryptoService.cs
  8. 4
      src/Core/Services/StateService.cs

8
src/App/Pages/Accounts/LockPageViewModel.cs

@ -33,7 +33,7 @@ namespace Bit.App.Pages @@ -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 @@ -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 @@ -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();
}

5
src/App/Pages/Accounts/LoginApproveDevicePage.xaml.cs

@ -15,7 +15,7 @@ namespace Bit.App.Pages @@ -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 @@ -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 @@ -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));
}

1
src/App/Pages/Accounts/LoginApproveDeviceViewModel.cs

@ -107,6 +107,7 @@ namespace Bit.App.Pages @@ -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;

6
src/App/Pages/Accounts/LoginPasswordlessRequestViewModel.cs

@ -237,7 +237,11 @@ namespace Bit.App.Pages @@ -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();
}
}

2
src/App/Pages/Accounts/LoginSsoPage.xaml.cs

@ -112,7 +112,7 @@ namespace Bit.App.Pages @@ -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())

9
src/App/Pages/Accounts/LoginSsoPageViewModel.cs

@ -31,7 +31,6 @@ namespace Bit.App.Pages @@ -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 @@ -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 @@ -84,8 +77,6 @@ namespace Bit.App.Pages
{
OrgIdentifier = await _stateService.GetRememberedOrgIdentifierAsync();
}
Email = await _stateService.GetRememberedEmailAsync();
}
catch (Exception ex)
{

5
src/Core/Services/DeviceTrustCryptoService.cs

@ -43,11 +43,6 @@ namespace Bit.Core.Services @@ -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)

4
src/Core/Services/StateService.cs

@ -1300,12 +1300,12 @@ namespace Bit.Core.Services @@ -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()

Loading…
Cancel
Save