mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
fix bugs around collection association
This commit is contained in:
@ -18,7 +18,7 @@ namespace Bit.Core.Repositories
|
||||
Task CreateAsync(CipherDetails cipher);
|
||||
Task ReplaceAsync(CipherDetails cipher);
|
||||
Task UpsertAsync(CipherDetails cipher);
|
||||
Task ReplaceAsync(Cipher obj, IEnumerable<Guid> collectionIds);
|
||||
Task<bool> ReplaceAsync(Cipher obj, IEnumerable<Guid> collectionIds);
|
||||
Task UpdatePartialAsync(Guid id, Guid userId, Guid? folderId, bool favorite);
|
||||
Task UpdateAttachmentAsync(CipherAttachment attachment);
|
||||
Task DeleteAttachmentAsync(Guid cipherId, string attachmentId);
|
||||
|
@ -152,17 +152,18 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ReplaceAsync(Cipher obj, IEnumerable<Guid> collectionIds)
|
||||
public async Task<bool> ReplaceAsync(Cipher obj, IEnumerable<Guid> collectionIds)
|
||||
{
|
||||
var objWithCollections = JsonConvert.DeserializeObject<CipherWithCollections>(JsonConvert.SerializeObject(obj));
|
||||
objWithCollections.CollectionIds = collectionIds.ToGuidIdArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
var result = await connection.ExecuteScalarAsync<int>(
|
||||
$"[{Schema}].[Cipher_UpdateWithCollections]",
|
||||
objWithCollections,
|
||||
commandType: CommandType.StoredProcedure);
|
||||
return result >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,11 @@ namespace Bit.Core.Services
|
||||
cipher.UserId = sharingUserId;
|
||||
cipher.OrganizationId = organizationId;
|
||||
cipher.RevisionDate = DateTime.UtcNow;
|
||||
await _cipherRepository.ReplaceAsync(cipher, collectionIds);
|
||||
if(!await _cipherRepository.ReplaceAsync(cipher, collectionIds))
|
||||
{
|
||||
throw new BadRequestException("Unable to save.");
|
||||
}
|
||||
|
||||
updatedCipher = true;
|
||||
|
||||
if(hasAttachments)
|
||||
|
Reference in New Issue
Block a user