mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
some remaining login => renames
This commit is contained in:
parent
1d6ec0f953
commit
0020bd0fb7
4 changed files with 22 additions and 27 deletions
|
@ -12,10 +12,10 @@ namespace Bit.App.Abstractions
|
||||||
Task<IEnumerable<Cipher>> GetAllAsync();
|
Task<IEnumerable<Cipher>> GetAllAsync();
|
||||||
Task<IEnumerable<Cipher>> GetAllAsync(bool favorites);
|
Task<IEnumerable<Cipher>> GetAllAsync(bool favorites);
|
||||||
Task<Tuple<IEnumerable<Cipher>, IEnumerable<Cipher>>> GetAllAsync(string uriString);
|
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<ApiResult> DeleteAsync(string id);
|
||||||
Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, string orgId = null);
|
Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, string orgId = null);
|
||||||
Task<ApiResult<CipherResponse>> EncryptAndSaveAttachmentAsync(Cipher login, byte[] data, string fileName);
|
Task<ApiResult<CipherResponse>> EncryptAndSaveAttachmentAsync(Cipher cipher, byte[] data, string fileName);
|
||||||
Task<ApiResult> DeleteAttachmentAsync(Cipher login, string attachmentId);
|
Task<ApiResult> DeleteAttachmentAsync(Cipher cipher, string attachmentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,6 @@ namespace Bit.App.Models
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
public string SizeName { get; set; }
|
public string SizeName { get; set; }
|
||||||
|
|
||||||
public AttachmentData ToAttachmentData(string loginId)
|
|
||||||
{
|
|
||||||
return new AttachmentData(this, loginId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetSize(string sizeString)
|
private void SetSize(string sizeString)
|
||||||
{
|
{
|
||||||
long size;
|
long size;
|
||||||
|
|
|
@ -152,7 +152,7 @@ namespace Bit.App.Pages
|
||||||
return;
|
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))
|
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 attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId);
|
||||||
var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList());
|
var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList());
|
||||||
var data = await _cipherRepository.GetAllByUserIdAsync(_authService.UserId);
|
var data = await _cipherRepository.GetAllByUserIdAsync(_authService.UserId);
|
||||||
var logins = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null));
|
var cipher = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null));
|
||||||
return logins;
|
return cipher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Cipher>> GetAllAsync(bool favorites)
|
public async Task<IEnumerable<Cipher>> GetAllAsync(bool favorites)
|
||||||
|
@ -65,8 +65,8 @@ namespace Bit.App.Services
|
||||||
var attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId);
|
var attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId);
|
||||||
var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList());
|
var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList());
|
||||||
var data = await _cipherRepository.GetAllByUserIdAsync(_authService.UserId, favorites);
|
var data = await _cipherRepository.GetAllByUserIdAsync(_authService.UserId, favorites);
|
||||||
var logins = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null));
|
var cipher = data.Select(f => new Cipher(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null));
|
||||||
return logins;
|
return cipher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Tuple<IEnumerable<Cipher>, IEnumerable<Cipher>>> GetAllAsync(string uriString)
|
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);
|
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;
|
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);
|
response = await _cipherApiRepository.PostAsync(request);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
response = await _cipherApiRepository.PutAsync(login.Id, request);
|
response = await _cipherApiRepository.PutAsync(cipher.Id, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response.Succeeded)
|
if(response.Succeeded)
|
||||||
{
|
{
|
||||||
var data = new CipherData(response.Result, _authService.UserId);
|
var data = new CipherData(response.Result, _authService.UserId);
|
||||||
if(login.Id == null)
|
if(cipher.Id == null)
|
||||||
{
|
{
|
||||||
await _cipherRepository.InsertAsync(data);
|
await _cipherRepository.InsertAsync(data);
|
||||||
login.Id = data.Id;
|
cipher.Id = data.Id;
|
||||||
}
|
}
|
||||||
else
|
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,
|
var encBytes = _cryptoService.EncryptToBytes(data,
|
||||||
login.OrganizationId != null ? _cryptoService.GetOrgKey(login.OrganizationId) : null);
|
cipher.OrganizationId != null ? _cryptoService.GetOrgKey(cipher.OrganizationId) : null);
|
||||||
var response = await _cipherApiRepository.PostAttachmentAsync(login.Id, encBytes, encFileName.EncryptedString);
|
var response = await _cipherApiRepository.PostAttachmentAsync(cipher.Id, encBytes, encFileName.EncryptedString);
|
||||||
|
|
||||||
if(response.Succeeded)
|
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)
|
foreach(var attachment in attachmentData)
|
||||||
{
|
{
|
||||||
await _attachmentRepository.UpsertAsync(attachment);
|
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
|
else if(response.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||||
|| response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
|| response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||||
|
@ -323,9 +323,9 @@ namespace Bit.App.Services
|
||||||
return response;
|
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)
|
if(response.Succeeded)
|
||||||
{
|
{
|
||||||
await _attachmentRepository.DeleteAsync(attachmentId);
|
await _attachmentRepository.DeleteAsync(attachmentId);
|
||||||
|
|
Loading…
Reference in a new issue