mirror of
https://github.com/bitwarden/mobile.git
synced 2024-09-28 03:57:43 +02:00
9fdf2ada6f
* Added account deletion feature on settings * Disabled using Microsoft.AppCenter.Crashes for FDroid * Moved drawable on Android.csproj to be with the others Co-authored-by: Federico Maccaroni <fmaccaroni@bitwarden.com>
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System.Threading.Tasks;
|
|
using Bit.App.Abstractions;
|
|
using Bit.App.Resources;
|
|
using Bit.Core.Abstractions;
|
|
using System;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.App.Services
|
|
{
|
|
public class MobilePasswordRepromptService : IPasswordRepromptService
|
|
{
|
|
private readonly IPlatformUtilsService _platformUtilsService;
|
|
private readonly ICryptoService _cryptoService;
|
|
|
|
public MobilePasswordRepromptService(IPlatformUtilsService platformUtilsService, ICryptoService cryptoService)
|
|
{
|
|
_platformUtilsService = platformUtilsService;
|
|
_cryptoService = cryptoService;
|
|
}
|
|
|
|
public string[] ProtectedFields { get; } = { "LoginTotp", "LoginPassword", "H_FieldValue", "CardNumber", "CardCode" };
|
|
|
|
public async Task<bool> ShowPasswordPromptAsync()
|
|
{
|
|
return await _platformUtilsService.ShowPasswordDialogAsync(AppResources.PasswordConfirmation, AppResources.PasswordConfirmationDesc, ValidatePasswordAsync);
|
|
}
|
|
|
|
public async Task<(string password, bool valid)> ShowPasswordPromptAndGetItAsync()
|
|
{
|
|
return await _platformUtilsService.ShowPasswordDialogAndGetItAsync(AppResources.PasswordConfirmation, AppResources.PasswordConfirmationDesc, ValidatePasswordAsync);
|
|
}
|
|
|
|
private async Task<bool> ValidatePasswordAsync(string password)
|
|
{
|
|
// Assume user has canceled.
|
|
if (string.IsNullOrWhiteSpace(password))
|
|
{
|
|
return false;
|
|
};
|
|
|
|
return await _cryptoService.CompareAndUpdateKeyHashAsync(password, null);
|
|
}
|
|
|
|
public async Task<bool> Enabled()
|
|
{
|
|
var keyConnectorService = ServiceContainer.Resolve<IKeyConnectorService>("keyConnectorService");
|
|
return !await keyConnectorService.GetUsesKeyConnector();
|
|
}
|
|
}
|
|
}
|