From 87fb5cf2aeed4aa35a6b80f6d7e3ac50e829d478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Filipe=20da=20Silva=20Bispo?= Date: Wed, 14 Sep 2022 14:45:39 +0100 Subject: [PATCH] [SG-659] Fixed TOTP not showing for free user with classic plans. (#2071) * [SG-659] Fixed TOTP not showing for free user with classic plans. * [SG-659] Ran code format --- src/App/Pages/Vault/CipherDetailsPageViewModel.cs | 4 ++-- .../Vault/GroupingsPage/GroupingsPageViewModel.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/App/Pages/Vault/CipherDetailsPageViewModel.cs b/src/App/Pages/Vault/CipherDetailsPageViewModel.cs index e90ace011..0c0411427 100644 --- a/src/App/Pages/Vault/CipherDetailsPageViewModel.cs +++ b/src/App/Pages/Vault/CipherDetailsPageViewModel.cs @@ -202,7 +202,7 @@ namespace Bit.App.Pages } } - public bool ShowUpgradePremiumTotpText => !CanAccessPremium && ShowTotp; + public bool ShowUpgradePremiumTotpText => !CanAccessPremium && !Cipher.OrganizationUseTotp && ShowTotp; public bool ShowUris => IsLogin && Cipher.Login.HasUris; public bool ShowIdentityAddress => IsIdentity && ( !string.IsNullOrWhiteSpace(Cipher.Identity.Address1) || @@ -216,7 +216,7 @@ namespace Bit.App.Pages public string PasswordVisibilityAccessibilityText => ShowPassword ? AppResources.PasswordIsVisibleTapToHide : AppResources.PasswordIsNotVisibleTapToShow; public string TotpCodeFormatted { - get => _canAccessPremium ? _totpCodeFormatted : string.Empty; + get => ShowUpgradePremiumTotpText ? string.Empty : _totpCodeFormatted; set => SetProperty(ref _totpCodeFormatted, value, additionalPropertyNames: new string[] { diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs index 006694b3c..cd626e2ee 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs @@ -200,7 +200,6 @@ namespace Bit.App.Pages { PageTitle = ShowVaultFilter ? AppResources.Vaults : AppResources.MyVault; } - var canAccessPremium = await _stateService.CanAccessPremiumAsync(); _doingLoad = true; LoadedOnce = true; ShowNoData = false; @@ -231,7 +230,7 @@ namespace Bit.App.Pages } if (MainPage) { - AddTotpGroupItem(canAccessPremium, groupedItems, uppercaseGroupNames); + AddTotpGroupItem(groupedItems, uppercaseGroupNames); groupedItems.Add(new GroupingsPageListGroup( AppResources.Types, 4, uppercaseGroupNames, !hasFavorites) @@ -382,9 +381,9 @@ namespace Bit.App.Pages } } - private void AddTotpGroupItem(bool canAccessPremium, List groupedItems, bool uppercaseGroupNames) + private void AddTotpGroupItem(List groupedItems, bool uppercaseGroupNames) { - if (canAccessPremium && TOTPCiphers?.Any() == true) + if (TOTPCiphers?.Any() == true) { groupedItems.Insert(0, new GroupingsPageListGroup( AppResources.Totp, 1, uppercaseGroupNames, false) @@ -537,10 +536,11 @@ namespace Bit.App.Pages private async Task LoadDataAsync() { + var canAccessPremium = await _stateService.CanAccessPremiumAsync(); NoDataText = AppResources.NoItems; _allCiphers = await GetAllCiphersAsync(); HasCiphers = _allCiphers.Any(); - TOTPCiphers = _allCiphers.Where(c => c.IsDeleted == Deleted && c.Type == CipherType.Login && !string.IsNullOrEmpty(c.Login?.Totp)).ToList(); + TOTPCiphers = _allCiphers.Where(c => c.IsDeleted == Deleted && c.Type == CipherType.Login && !string.IsNullOrEmpty(c.Login?.Totp) && (c.OrganizationUseTotp || canAccessPremium)).ToList(); FavoriteCiphers?.Clear(); NoFolderCiphers?.Clear(); _folderCounts.Clear();