1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 16:53:26 +00:00

make sure totp copy isn't available if not premium

This commit is contained in:
Kyle Spearrin
2019-06-13 08:44:07 -04:00
parent 6c5979040f
commit 43cee53dc8
2 changed files with 17 additions and 8 deletions

View File

@@ -651,15 +651,19 @@ namespace Bit.Droid.Services
private async Task CopyTotpAsync(CipherView cipher)
{
var autoCopyDisabled = await _storageService.GetAsync<bool?>(Constants.DisableAutoTotpCopyKey);
var canAccessPremium = await ServiceContainer.Resolve<IUserService>("userService").CanAccessPremiumAsync();
if((canAccessPremium || cipher.OrganizationUseTotp) && !autoCopyDisabled.GetValueOrDefault() &&
!string.IsNullOrWhiteSpace(cipher?.Login?.Totp))
if(!string.IsNullOrWhiteSpace(cipher?.Login?.Totp))
{
var totp = await ServiceContainer.Resolve<ITotpService>("totpService").GetCodeAsync(cipher.Login.Totp);
if(totp != null)
var userService = ServiceContainer.Resolve<IUserService>("userService");
var autoCopyDisabled = await _storageService.GetAsync<bool?>(Constants.DisableAutoTotpCopyKey);
var canAccessPremium = await userService.CanAccessPremiumAsync();
if((canAccessPremium || cipher.OrganizationUseTotp) && !autoCopyDisabled.GetValueOrDefault())
{
CopyToClipboard(totp);
var totpService = ServiceContainer.Resolve<ITotpService>("totpService");
var totp = await totpService.GetCodeAsync(cipher.Login.Totp);
if(totp != null)
{
CopyToClipboard(totp);
}
}
}
}