mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
PM-4314 Removed move passkey to organization duplicate check (#2828)
This commit is contained in:
parent
ed3467515e
commit
72de17bd1d
5 changed files with 3 additions and 48 deletions
|
@ -113,15 +113,9 @@ namespace Bit.App.Pages
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
|
await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
|
||||||
var error = await _cipherService.ShareWithServerAsync(cipherView, OrganizationId, checkedCollectionIds);
|
await _cipherService.ShareWithServerAsync(cipherView, OrganizationId, checkedCollectionIds);
|
||||||
await _deviceActionService.HideLoadingAsync();
|
await _deviceActionService.HideLoadingAsync();
|
||||||
|
|
||||||
if (error == ICipherService.ShareWithServerError.DuplicatedPasskeyInOrg)
|
|
||||||
{
|
|
||||||
_platformUtilsService.ShowToast(null, null, AppResources.ThisItemCannotBeSharedWithTheOrganizationBecauseThereIsOneAlreadyWithTheSamePasskey);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var movedItemToOrgText = string.Format(AppResources.MovedItemToOrg, cipherView.Name,
|
var movedItemToOrgText = string.Format(AppResources.MovedItemToOrg, cipherView.Name,
|
||||||
(await _organizationService.GetAsync(OrganizationId)).Name);
|
(await _organizationService.GetAsync(OrganizationId)).Name);
|
||||||
_platformUtilsService.ShowToast("success", null, movedItemToOrgText);
|
_platformUtilsService.ShowToast("success", null, movedItemToOrgText);
|
||||||
|
|
10
src/App/Resources/AppResources.Designer.cs
generated
10
src/App/Resources/AppResources.Designer.cs
generated
|
@ -6659,16 +6659,6 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to This item cannot be shared with the organization because there is one already with the same passkey..
|
|
||||||
/// </summary>
|
|
||||||
public static string ThisItemCannotBeSharedWithTheOrganizationBecauseThereIsOneAlreadyWithTheSamePasskey {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("ThisItemCannotBeSharedWithTheOrganizationBecauseThereIsOneAlreadyWithTheSamePassk" +
|
|
||||||
"ey", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to This request is no longer valid.
|
/// Looks up a localized string similar to This request is no longer valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -2691,9 +2691,6 @@ Do you want to switch to this account?</value>
|
||||||
<data name="VaultTimeoutActionChangedToLogOut" xml:space="preserve">
|
<data name="VaultTimeoutActionChangedToLogOut" xml:space="preserve">
|
||||||
<value>Vault timeout action changed to log out</value>
|
<value>Vault timeout action changed to log out</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ThisItemCannotBeSharedWithTheOrganizationBecauseThereIsOneAlreadyWithTheSamePasskey" xml:space="preserve">
|
|
||||||
<value>This item cannot be shared with the organization because there is one already with the same passkey.</value>
|
|
||||||
</data>
|
|
||||||
<data name="BlockAutoFill" xml:space="preserve">
|
<data name="BlockAutoFill" xml:space="preserve">
|
||||||
<value>Block auto-fill</value>
|
<value>Block auto-fill</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -10,12 +10,6 @@ namespace Bit.Core.Abstractions
|
||||||
{
|
{
|
||||||
public interface ICipherService
|
public interface ICipherService
|
||||||
{
|
{
|
||||||
public enum ShareWithServerError
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
DuplicatedPasskeyInOrg
|
|
||||||
}
|
|
||||||
|
|
||||||
Task ClearAsync(string userId);
|
Task ClearAsync(string userId);
|
||||||
Task ClearCacheAsync();
|
Task ClearCacheAsync();
|
||||||
Task DeleteAsync(List<string> ids);
|
Task DeleteAsync(List<string> ids);
|
||||||
|
@ -36,7 +30,7 @@ namespace Bit.Core.Abstractions
|
||||||
Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data);
|
Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data);
|
||||||
Task SaveCollectionsWithServerAsync(Cipher cipher);
|
Task SaveCollectionsWithServerAsync(Cipher cipher);
|
||||||
Task SaveWithServerAsync(Cipher cipher);
|
Task SaveWithServerAsync(Cipher cipher);
|
||||||
Task<ShareWithServerError> ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds);
|
Task ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds);
|
||||||
Task UpdateLastUsedDateAsync(string id);
|
Task UpdateLastUsedDateAsync(string id);
|
||||||
Task UpsertAsync(CipherData cipher);
|
Task UpsertAsync(CipherData cipher);
|
||||||
Task UpsertAsync(List<CipherData> cipher);
|
Task UpsertAsync(List<CipherData> cipher);
|
||||||
|
|
|
@ -564,13 +564,8 @@ namespace Bit.Core.Services
|
||||||
await UpsertAsync(data);
|
await UpsertAsync(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ICipherService.ShareWithServerError> ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds)
|
public async Task ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds)
|
||||||
{
|
{
|
||||||
if (!await ValidateCanBeSharedWithOrgAsync(cipher, organizationId))
|
|
||||||
{
|
|
||||||
return ICipherService.ShareWithServerError.DuplicatedPasskeyInOrg;
|
|
||||||
}
|
|
||||||
|
|
||||||
var attachmentTasks = new List<Task>();
|
var attachmentTasks = new List<Task>();
|
||||||
if (cipher.Attachments != null)
|
if (cipher.Attachments != null)
|
||||||
{
|
{
|
||||||
|
@ -591,21 +586,6 @@ namespace Bit.Core.Services
|
||||||
var userId = await _stateService.GetActiveUserIdAsync();
|
var userId = await _stateService.GetActiveUserIdAsync();
|
||||||
var data = new CipherData(response, userId, collectionIds);
|
var data = new CipherData(response, userId, collectionIds);
|
||||||
await UpsertAsync(data);
|
await UpsertAsync(data);
|
||||||
|
|
||||||
return ICipherService.ShareWithServerError.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<bool> ValidateCanBeSharedWithOrgAsync(CipherView cipher, string organizationId)
|
|
||||||
{
|
|
||||||
if (!cipher.HasFido2Credential)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var decCiphers = await GetAllDecryptedAsync();
|
|
||||||
return !decCiphers
|
|
||||||
.Where(c => c.OrganizationId == organizationId)
|
|
||||||
.Any(c => !cipher.Login.MainFido2Credential.IsUniqueAgainst(c.Login?.MainFido2Credential));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data)
|
public async Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data)
|
||||||
|
|
Loading…
Reference in a new issue