diff --git a/src/Api/Controllers/AccountsController.cs b/src/Api/Controllers/AccountsController.cs index 298a82a28b..142783a5e9 100644 --- a/src/Api/Controllers/AccountsController.cs +++ b/src/Api/Controllers/AccountsController.cs @@ -285,7 +285,7 @@ namespace Bit.Api.Controllers throw new UnauthorizedAccessException(); } - var ciphers = new List(); + List ciphers = null; if (model.Ciphers.Any()) { var existingCiphers = await _cipherRepository.GetManyByUserIdAsync(user.Id); @@ -294,7 +294,7 @@ namespace Bit.Api.Controllers .ToList(); } - var folders = new List(); + List folders = null; if (model.Folders.Any()) { var existingFolders = await _folderRepository.GetManyByUserIdAsync(user.Id); @@ -303,7 +303,7 @@ namespace Bit.Api.Controllers .ToList(); } - var sends = new List(); + List sends = null; if (model.Sends?.Any() == true) { var existingSends = await _sendRepository.GetManyByUserIdAsync(user.Id); diff --git a/src/Core/Repositories/SqlServer/CipherRepository.cs b/src/Core/Repositories/SqlServer/CipherRepository.cs index ed7f65757c..47f1da4e8a 100644 --- a/src/Core/Repositories/SqlServer/CipherRepository.cs +++ b/src/Core/Repositories/SqlServer/CipherRepository.cs @@ -336,7 +336,7 @@ namespace Bit.Core.Repositories.SqlServer // 3. Bulk copy into temp tables. - if (ciphers.Any()) + if (ciphers?.Any() == true) { using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction)) { @@ -346,7 +346,7 @@ namespace Bit.Core.Repositories.SqlServer } } - if (folders.Any()) + if (folders?.Any() == true) { using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction)) { @@ -356,7 +356,7 @@ namespace Bit.Core.Repositories.SqlServer } } - if (sends.Any()) + if (sends?.Any() == true) { using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction)) { @@ -370,7 +370,7 @@ namespace Bit.Core.Repositories.SqlServer var sql = string.Empty; - if (ciphers.Any()) + if (ciphers?.Any() == true) { sql += @" UPDATE @@ -387,7 +387,7 @@ namespace Bit.Core.Repositories.SqlServer C.[UserId] = @UserId"; } - if (folders.Any()) + if (folders?.Any() == true) { sql += @" UPDATE @@ -403,7 +403,7 @@ namespace Bit.Core.Repositories.SqlServer F.[UserId] = @UserId"; } - if (sends.Any()) + if (sends?.Any() == true) { sql += @" UPDATE diff --git a/src/Core/Services/Implementations/UserService.cs b/src/Core/Services/Implementations/UserService.cs index 0222715489..a6f5e778f3 100644 --- a/src/Core/Services/Implementations/UserService.cs +++ b/src/Core/Services/Implementations/UserService.cs @@ -742,7 +742,7 @@ namespace Bit.Core.Services user.SecurityStamp = Guid.NewGuid().ToString(); user.Key = key; user.PrivateKey = privateKey; - if (ciphers.Any() || folders.Any() || sends.Any()) + if (ciphers?.Any() == true || folders?.Any() == true || sends?.Any() == true) { await _cipherRepository.UpdateUserKeysAndCiphersAsync(user, ciphers, folders, sends); }