Skip to content

Commit

Permalink
[AC-2788] Remove unassigned items feature flag and logic (#3300)
Browse files Browse the repository at this point in the history
  • Loading branch information
fedemkr authored Jun 19, 2024
1 parent cf5c5aa commit 9edcc8b
Show file tree
Hide file tree
Showing 19 changed files with 2 additions and 182 deletions.
1 change: 0 additions & 1 deletion src/Core/Abstractions/IApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public interface IApiService
Task<CipherResponse> PutShareCipherAsync(string id, CipherShareRequest request);
Task PutDeleteCipherAsync(string id);
Task<CipherResponse> PutRestoreCipherAsync(string id);
Task<bool> HasUnassignedCiphersAsync();
Task RefreshIdentityTokenAsync();
Task<SsoPrevalidateResponse> PreValidateSsoAsync(string identifier);
Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path,
Expand Down
1 change: 0 additions & 1 deletion src/Core/Abstractions/ICipherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ Task<Tuple<List<CipherView>, List<CipherView>, List<CipherView>>> GetAllDecrypte
Task RestoreWithServerAsync(string id);
Task<string> CreateNewLoginForPasskeyAsync(Fido2ConfirmNewCredentialParams newPasskeyParams);
Task CopyTotpCodeIfNeededAsync(CipherView cipher);
Task<bool> VerifyOrganizationHasUnassignedItemsAsync();
}
}
2 changes: 0 additions & 2 deletions src/Core/Abstractions/IStateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ public interface IStateService
Task<BwRegion?> GetPreAuthRegionAsync();
Task SetPreAuthRegionAsync(BwRegion value);
Task ReloadStateAsync();
Task<bool> GetShouldCheckOrganizationUnassignedItemsAsync(string userId = null);
Task SetShouldCheckOrganizationUnassignedItemsAsync(bool shouldCheck, string userId = null);
[Obsolete("Use GetPinKeyEncryptedUserKeyAsync instead, left for migration purposes")]
Task<string> GetPinProtectedAsync(string userId = null);
[Obsolete("Use SetPinKeyEncryptedUserKeyAsync instead, left for migration purposes")]
Expand Down
2 changes: 0 additions & 2 deletions src/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static class Constants
public const string PasswordlessLoginRequestKey = "passwordlessLoginRequest";
public const string PreLoginEmailKey = "preLoginEmailKey";
public const string ConfigsKey = "configsKey";
public const string UnassignedItemsBannerFlag = "unassigned-items-banner";
public const string RegionEnvironment = "regionEnvironment";
public const string DuoCallback = "bitwarden://duo-callback";
public const string NavigateToMessageCommand = "navigateTo";
Expand Down Expand Up @@ -138,7 +137,6 @@ public static string AccountBiometricIntegrityValidKey(string userId, string sys
public static string ShouldConnectToWatchKey(string userId) => $"shouldConnectToWatch_{userId}";
public static string ScreenCaptureAllowedKey(string userId) => $"screenCaptureAllowed_{userId}";
public static string PendingAdminAuthRequest(string userId) => $"pendingAdminAuthRequest_{userId}";
public static string ShouldCheckOrganizationUnassignedItemsKey(string userId) => $"shouldCheckOrganizationUnassignedItems_{userId}";
[Obsolete]
public static string KeyKey(string userId) => $"key_{userId}";
[Obsolete]
Expand Down
1 change: 0 additions & 1 deletion src/Core/Models/AppOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class AppOptions
public bool HideAccountSwitcher { get; set; }
public OtpData? OtpData { get; set; }
public bool HasUnlockedInThisTransaction { get; set; }
public bool HasJustLoggedInOrUnlocked { get; set; }

public void SetAllFrom(AppOptions o)
{
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Pages/Accounts/LockPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@ private async Task UnlockedAsync()
return;
}
var previousPage = await AppHelpers.ClearPreviousPage();

if (_appOptions != null)
{
_appOptions.HasJustLoggedInOrUnlocked = true;
}
App.MainPage = new TabsPage(_appOptions, previousPage);
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Pages/Accounts/LoginApproveDevicePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ private async Task ContinueToVaultAsync()
{
return;
}

if (_appOptions != null)
{
_appOptions.HasJustLoggedInOrUnlocked = true;
}
var previousPage = await AppHelpers.ClearPreviousPage();
App.MainPage = new TabsPage(_appOptions, previousPage);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Pages/Accounts/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ private async Task LogInSuccessAsync()
{
return;
}

if (_appOptions != null)
{
_appOptions.HasJustLoggedInOrUnlocked = true;
}
var previousPage = await AppHelpers.ClearPreviousPage();
App.MainPage = new TabsPage(_appOptions, previousPage);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Pages/Accounts/LoginPasswordlessRequestPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ private async Task LogInSuccessAsync()
{
return;
}

if (_appOptions != null)
{
_appOptions.HasJustLoggedInOrUnlocked = true;
}
var previousPage = await AppHelpers.ClearPreviousPage();
App.MainPage = new TabsPage(_appOptions, previousPage);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Pages/Accounts/SetPasswordPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ private async Task SetPasswordSuccessAsync()
{
return;
}

if (_appOptions != null)
{
_appOptions.HasJustLoggedInOrUnlocked = true;
}
var previousPage = await AppHelpers.ClearPreviousPage();
App.MainPage = new TabsPage(_appOptions, previousPage);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Pages/Accounts/TwoFactorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ private async Task TwoFactorAuthSuccessToMainAsync()
{
return;
}

if (_appOptions != null)
{
_appOptions.HasJustLoggedInOrUnlocked = true;
}
var previousPage = await AppHelpers.ClearPreviousPage();
App.MainPage = new TabsPage(_appOptions, previousPage);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Pages/TabsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = nu
_keyConnectorService = ServiceContainer.Resolve<IKeyConnectorService>("keyConnectorService");
_stateService = ServiceContainer.Resolve<IStateService>();

_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage, appOptions: appOptions))
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
{
Title = AppResources.MyVault,
IconImageSource = "lock.png"
Expand Down
5 changes: 1 addition & 4 deletions src/Core/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class GroupingsPage : BaseContentPage

public GroupingsPage(bool mainPage, CipherType? type = null, string folderId = null,
string collectionId = null, string pageTitle = null, string vaultFilterSelection = null,
PreviousPageInfo previousPage = null, bool deleted = false, bool showTotp = false, AppOptions appOptions = null)
PreviousPageInfo previousPage = null, bool deleted = false, bool showTotp = false)
{
_pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks);
InitializeComponent();
Expand All @@ -51,7 +51,6 @@ public GroupingsPage(bool mainPage, CipherType? type = null, string folderId = n
_vm.CollectionId = collectionId;
_vm.Deleted = deleted;
_vm.ShowTotp = showTotp;
_vm.AppOptions = appOptions;
_previousPage = previousPage;
if (pageTitle != null)
{
Expand Down Expand Up @@ -162,8 +161,6 @@ await LoadOnAppearedAsync(_mainLayout, false, async () =>
return;
}

await _vm.CheckOrganizationUnassignedItemsAsync();

// Push registration
var lastPushRegistration = await _stateService.GetPushLastRegistrationDateAsync();
lastPushRegistration = lastPushRegistration.GetValueOrDefault(DateTime.MinValue);
Expand Down
59 changes: 0 additions & 59 deletions src/Core/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public class GroupingsPageViewModel : VaultFilterViewModel
private readonly IPasswordRepromptService _passwordRepromptService;
private readonly IOrganizationService _organizationService;
private readonly IPolicyService _policyService;
private readonly IConfigService _configService;
private readonly IEnvironmentService _environmentService;
private readonly ILogger _logger;

public GroupingsPageViewModel()
Expand All @@ -64,8 +62,6 @@ public GroupingsPageViewModel()
_passwordRepromptService = ServiceContainer.Resolve<IPasswordRepromptService>("passwordRepromptService");
_organizationService = ServiceContainer.Resolve<IOrganizationService>("organizationService");
_policyService = ServiceContainer.Resolve<IPolicyService>("policyService");
_configService = ServiceContainer.Resolve<IConfigService>();
_environmentService = ServiceContainer.Resolve<IEnvironmentService>();
_logger = ServiceContainer.Resolve<ILogger>("logger");

Loading = true;
Expand Down Expand Up @@ -109,7 +105,6 @@ public GroupingsPageViewModel()
public List<Core.Models.View.CollectionView> Collections { get; set; }
public List<TreeNode<Core.Models.View.CollectionView>> NestedCollections { get; set; }

public AppOptions AppOptions { get; internal set; }
protected override ICipherService cipherService => _cipherService;
protected override IPolicyService policyService => _policyService;
protected override IOrganizationService organizationService => _organizationService;
Expand Down Expand Up @@ -705,59 +700,5 @@ private List<FolderView> BuildFolders(List<FolderView> decFolders)
var folders = decFolders.Where(f => _allCiphers.Any(c => c.FolderId == f.Id)).ToList();
return folders.Any() ? folders : null;
}

internal async Task CheckOrganizationUnassignedItemsAsync()
{
try
{
if (AppOptions?.HasJustLoggedInOrUnlocked != true)
{
return;
}

AppOptions.HasJustLoggedInOrUnlocked = false;

if (!await _configService.GetFeatureFlagBoolAsync(Core.Constants.UnassignedItemsBannerFlag)
||
!await _stateService.GetShouldCheckOrganizationUnassignedItemsAsync())
{
return;
}

var waitSyncTask = Task.Run(async () =>
{
while (_syncService.SyncInProgress)
{
await Task.Delay(100);
}
});
await waitSyncTask.WaitAsync(TimeSpan.FromMinutes(5));

if (!await _cipherService.VerifyOrganizationHasUnassignedItemsAsync())
{
return;
}

var message = _environmentService.SelectedRegion == Core.Enums.Region.SelfHosted
? AppResources.OrganizationUnassignedItemsMessageSelfHost041624DescriptionLong
: AppResources.OrganizationUnassignedItemsMessageUSEUDescriptionLong;

var response = await _deviceActionService.DisplayAlertAsync(AppResources.Notice,
message,
null,
AppResources.RemindMeLater,
AppResources.Ok);

if (response == AppResources.Ok)
{
await _stateService.SetShouldCheckOrganizationUnassignedItemsAsync(false);
}
}
catch (TimeoutException) { }
catch (Exception ex)
{
_logger.Exception(ex);
}
}
}
}
36 changes: 0 additions & 36 deletions src/Core/Resources/Localization/AppResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions src/Core/Resources/Localization/AppResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2975,18 +2975,6 @@ Do you want to switch to this account?</value>
<data name="YourPasskeyWillBeSavedToYourBitwardenVaultForX" xml:space="preserve">
<value>Your passkey will be saved to your Bitwarden vault for {0}</value>
</data>
<data name="OrganizationUnassignedItemsMessageUSEUDescriptionLong" xml:space="preserve">
<value>Unassigned organization items are no longer visible in the All Vaults view and only accessible via the Admin Console. Assign these items to a collection from the Admin Console to make them visible.</value>
</data>
<data name="OrganizationUnassignedItemsMessageSelfHost041624DescriptionLong" xml:space="preserve">
<value>On May 16, 2024, unassigned organization items will no longer be visible in the All Vaults view and only accessible via the Admin Console. Assign these items to a collection from the Admin Console to make them visible.</value>
</data>
<data name="RemindMeLater" xml:space="preserve">
<value>Remind me later</value>
</data>
<data name="Notice" xml:space="preserve">
<value>Notice</value>
</data>
<data name="PasskeysNotSupportedForThisApp" xml:space="preserve">
<value>Passkeys not supported for this app</value>
</data>
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Services/ApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ public Task<CipherResponse> PutRestoreCipherAsync(string id)
return SendAsync<object, CipherResponse>(HttpMethod.Put, string.Concat("/ciphers/", id, "/restore"), null, true, true);
}

public Task<bool> HasUnassignedCiphersAsync()
{
return SendAsync<object, bool>(HttpMethod.Get, "/ciphers/has-unassigned-ciphers", null, true, true);
}

#endregion

#region Attachments APIs
Expand Down
18 changes: 0 additions & 18 deletions src/Core/Services/CipherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -835,24 +835,6 @@ public async Task RestoreWithServerAsync(string id)
await ClearCacheAsync();
}

public async Task<bool> VerifyOrganizationHasUnassignedItemsAsync()
{
var organizations = await _stateService.GetOrganizationsAsync();
if (organizations?.Any() != true)
{
return false;
}

try
{
return await _apiService.HasUnassignedCiphersAsync();
}
catch (ApiException ex) when (ex.Error?.StatusCode == System.Net.HttpStatusCode.BadRequest)
{
return false;
}
}

// Helpers

private async Task<Tuple<SymmetricCryptoKey, EncString, SymmetricCryptoKey>> MakeAttachmentKeyAsync(string organizationId, Cipher cipher = null, CipherView cipherView = null)
Expand Down
10 changes: 0 additions & 10 deletions src/Core/Services/StateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,16 +1384,6 @@ public async Task SetPreAuthRegionAsync(BwRegion value)
await _storageMediatorService.SaveAsync(Constants.RegionEnvironment, value);
}

public async Task<bool> GetShouldCheckOrganizationUnassignedItemsAsync(string userId = null)
{
return await _storageMediatorService.GetAsync<bool?>(await ComposeKeyAsync(Constants.ShouldCheckOrganizationUnassignedItemsKey, userId)) ?? true;
}

public async Task SetShouldCheckOrganizationUnassignedItemsAsync(bool shouldCheck, string userId = null)
{
await _storageMediatorService.SaveAsync<bool?>(await ComposeKeyAsync(Constants.ShouldCheckOrganizationUnassignedItemsKey, userId), shouldCheck);
}

// Helpers

[Obsolete("Use IStorageMediatorService instead")]
Expand Down

0 comments on commit 9edcc8b

Please sign in to comment.