mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-27 12:26:31 +01:00
some remaining login => renames
This commit is contained in:
parent
1d6ec0f953
commit
0020bd0fb7
@ -12,10 +12,10 @@ namespace Bit.App.Abstractions
|
||||
Task<IEnumerable<Cipher>> GetAllAsync();
|
||||
Task<IEnumerable<Cipher>> GetAllAsync(bool favorites);
|
||||
Task<Tuple<IEnumerable<Cipher>, IEnumerable<Cipher>>> GetAllAsync(string uriString);
|
||||
Task<ApiResult<CipherResponse>> SaveAsync(Cipher login);
|
||||
Task<ApiResult<CipherResponse>> SaveAsync(Cipher cipher);
|
||||
Task<ApiResult> DeleteAsync(string id);
|
||||
Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, string orgId = null);
|
||||
Task<ApiResult<CipherResponse>> EncryptAndSaveAttachmentAsync(Cipher login, byte[] data, string fileName);
|
||||
Task<ApiResult> DeleteAttachmentAsync(Cipher login, string attachmentId);
|
||||
Task<ApiResult<CipherResponse>> EncryptAndSaveAttachmentAsync(Cipher cipher, byte[] data, string fileName);
|
||||
Task<ApiResult> DeleteAttachmentAsync(Cipher cipher, string attachmentId);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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<IEnumerable<Cipher>> 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<Tuple<IEnumerable<Cipher>, IEnumerable<Cipher>>> GetAllAsync(string uriString)
|
||||
@ -212,27 +212,27 @@ namespace Bit.App.Services
|
||||
return new Tuple<IEnumerable<Cipher>, IEnumerable<Cipher>>(matchingLogins, matchingFuzzyLogins);
|
||||
}
|
||||
|
||||
public async Task<ApiResult<CipherResponse>> SaveAsync(Cipher login)
|
||||
public async Task<ApiResult<CipherResponse>> SaveAsync(Cipher cipher)
|
||||
{
|
||||
ApiResult<CipherResponse> 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<ApiResult<CipherResponse>> EncryptAndSaveAttachmentAsync(Cipher login, byte[] data, string fileName)
|
||||
public async Task<ApiResult<CipherResponse>> 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<ApiResult> DeleteAttachmentAsync(Cipher login, string attachmentId)
|
||||
public async Task<ApiResult> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user