mirror of
https://github.com/bitwarden/mobile
synced 2025-12-11 05:43:30 +00:00
* Add HashPurpose parameter to HashPasswordAsync
* Use 2 iterations for local password hashing
* Force logout if user has old keyHash stored
* Revert "Force logout if user has old keyHash stored"
This reverts commit 497d4928fa.
* Add backwards compatability with existing keyHash
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.Threading.Tasks;
|
|
using Bit.Core.Abstractions;
|
|
using Bit.App.Abstractions;
|
|
using Bit.App.Resources;
|
|
using System;
|
|
|
|
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()
|
|
{
|
|
Func<string, Task<bool>> validator = async (string password) =>
|
|
{
|
|
// Assume user has canceled.
|
|
if (string.IsNullOrWhiteSpace(password))
|
|
{
|
|
return false;
|
|
};
|
|
|
|
return await _cryptoService.CompareAndUpdateKeyHashAsync(password, null);
|
|
};
|
|
|
|
return await _platformUtilsService.ShowPasswordDialogAsync(AppResources.PasswordConfirmation, AppResources.PasswordConfirmationDesc, validator);
|
|
}
|
|
}
|
|
}
|