diff --git a/src/App/Abstractions/Services/ICipherService.cs b/src/App/Abstractions/Services/ICipherService.cs index 428130bff..dead4d00f 100644 --- a/src/App/Abstractions/Services/ICipherService.cs +++ b/src/App/Abstractions/Services/ICipherService.cs @@ -12,10 +12,10 @@ namespace Bit.App.Abstractions Task> GetAllAsync(); Task> GetAllAsync(bool favorites); Task, IEnumerable>> GetAllAsync(string uriString); - Task> SaveAsync(Cipher login); + Task> SaveAsync(Cipher cipher); Task DeleteAsync(string id); Task DownloadAndDecryptAttachmentAsync(string url, string orgId = null); - Task> EncryptAndSaveAttachmentAsync(Cipher login, byte[] data, string fileName); - Task DeleteAttachmentAsync(Cipher login, string attachmentId); + Task> EncryptAndSaveAttachmentAsync(Cipher cipher, byte[] data, string fileName); + Task DeleteAttachmentAsync(Cipher cipher, string attachmentId); } } diff --git a/src/App/Models/Attachment.cs b/src/App/Models/Attachment.cs index 7f328db90..0c402b3a2 100644 --- a/src/App/Models/Attachment.cs +++ b/src/App/Models/Attachment.cs @@ -32,11 +32,6 @@ namespace Bit.App.Models public long Size { get; set; } public string SizeName { get; set; } - public AttachmentData ToAttachmentData(string loginId) - { - return new AttachmentData(this, loginId); - } - private void SetSize(string sizeString) { long size; diff --git a/src/App/Pages/Settings/SettingsEditFolderPage.cs b/src/App/Pages/Settings/SettingsEditFolderPage.cs index 8daa8dd64..dd66619d3 100644 --- a/src/App/Pages/Settings/SettingsEditFolderPage.cs +++ b/src/App/Pages/Settings/SettingsEditFolderPage.cs @@ -152,7 +152,7 @@ namespace Bit.App.Pages return; } - // TODO: Validate the delete operation. ex. Cannot delete a folder that has logins in it? + // TODO: Validate the delete operation. ex. Cannot delete a folder that has ciphers in it? if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) { diff --git a/src/App/Services/CipherService.cs b/src/App/Services/CipherService.cs index c4f1b7417..b8a1233ce 100644 --- a/src/App/Services/CipherService.cs +++ b/src/App/Services/CipherService.cs @@ -56,8 +56,8 @@ namespace Bit.App.Services var attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId); var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList()); var data = await _cipherRepository.GetAllByUserIdAsync(_authService.UserId); - var logins = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null)); - return logins; + var cipher = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null)); + return cipher; } public async Task> GetAllAsync(bool favorites) @@ -65,8 +65,8 @@ namespace Bit.App.Services var attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId); var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList()); var data = await _cipherRepository.GetAllByUserIdAsync(_authService.UserId, favorites); - var logins = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null)); - return logins; + var cipher = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null)); + return cipher; } public async Task, IEnumerable>> GetAllAsync(string uriString) @@ -212,27 +212,27 @@ namespace Bit.App.Services return new Tuple, IEnumerable>(matchingLogins, matchingFuzzyLogins); } - public async Task> SaveAsync(Cipher login) + public async Task> SaveAsync(Cipher cipher) { ApiResult response = null; - var request = new CipherRequest(login); + var request = new CipherRequest(cipher); - if(login.Id == null) + if(cipher.Id == null) { response = await _cipherApiRepository.PostAsync(request); } else { - response = await _cipherApiRepository.PutAsync(login.Id, request); + response = await _cipherApiRepository.PutAsync(cipher.Id, request); } if(response.Succeeded) { var data = new CipherData(response.Result, _authService.UserId); - if(login.Id == null) + if(cipher.Id == null) { await _cipherRepository.InsertAsync(data); - login.Id = data.Id; + cipher.Id = data.Id; } else { @@ -298,21 +298,21 @@ namespace Bit.App.Services } } - public async Task> EncryptAndSaveAttachmentAsync(Cipher login, byte[] data, string fileName) + public async Task> EncryptAndSaveAttachmentAsync(Cipher cipher, byte[] data, string fileName) { - var encFileName = fileName.Encrypt(login.OrganizationId); + var encFileName = fileName.Encrypt(cipher.OrganizationId); var encBytes = _cryptoService.EncryptToBytes(data, - login.OrganizationId != null ? _cryptoService.GetOrgKey(login.OrganizationId) : null); - var response = await _cipherApiRepository.PostAttachmentAsync(login.Id, encBytes, encFileName.EncryptedString); + cipher.OrganizationId != null ? _cryptoService.GetOrgKey(cipher.OrganizationId) : null); + var response = await _cipherApiRepository.PostAttachmentAsync(cipher.Id, encBytes, encFileName.EncryptedString); if(response.Succeeded) { - var attachmentData = response.Result.Attachments.Select(a => new AttachmentData(a, login.Id)); + var attachmentData = response.Result.Attachments.Select(a => new AttachmentData(a, cipher.Id)); foreach(var attachment in attachmentData) { await _attachmentRepository.UpsertAsync(attachment); } - login.Attachments = response.Result.Attachments.Select(a => new Attachment(a)); + cipher.Attachments = response.Result.Attachments.Select(a => new Attachment(a)); } else if(response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized) @@ -323,9 +323,9 @@ namespace Bit.App.Services return response; } - public async Task DeleteAttachmentAsync(Cipher login, string attachmentId) + public async Task DeleteAttachmentAsync(Cipher cipher, string attachmentId) { - var response = await _cipherApiRepository.DeleteAttachmentAsync(login.Id, attachmentId); + var response = await _cipherApiRepository.DeleteAttachmentAsync(cipher.Id, attachmentId); if(response.Succeeded) { await _attachmentRepository.DeleteAsync(attachmentId);