1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 00:52:49 -05:00

[AC-1116] Assign new imported collections to the importing user with Manage permission (#3424)

* [AC-1116] Assigning imported collections to the importing user with Manage permission

* [AC-1116] Added unit tests
This commit is contained in:
Rui Tomé
2023-11-23 12:21:20 +00:00
committed by GitHub
parent 4e8284cf81
commit e2d644f136
5 changed files with 148 additions and 9 deletions

View File

@ -161,7 +161,10 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
}
}
public async Task CreateAsync(IEnumerable<Core.Vault.Entities.Cipher> ciphers, IEnumerable<Core.Entities.Collection> collections, IEnumerable<Core.Entities.CollectionCipher> collectionCiphers)
public async Task CreateAsync(IEnumerable<Core.Vault.Entities.Cipher> ciphers,
IEnumerable<Core.Entities.Collection> collections,
IEnumerable<Core.Entities.CollectionCipher> collectionCiphers,
IEnumerable<Core.Entities.CollectionUser> collectionUsers)
{
if (!ciphers.Any())
{
@ -184,6 +187,13 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
var collectionCipherEntities = Mapper.Map<List<CollectionCipher>>(collectionCiphers);
await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, collectionCipherEntities);
}
if (collectionUsers.Any())
{
var collectionUserEntities = Mapper.Map<List<CollectionUser>>(collectionUsers);
await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, collectionUserEntities);
}
await dbContext.UserBumpAccountRevisionDateByOrganizationIdAsync(ciphers.First().OrganizationId.Value);
await dbContext.SaveChangesAsync();
}