1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +01:00

rename pages and props for login => cipher

This commit is contained in:
Kyle Spearrin 2017-10-19 14:30:12 -04:00
parent 58ebabf74c
commit d146870a74
7 changed files with 56 additions and 57 deletions

View File

@ -355,8 +355,8 @@
<Compile Include="Pages\LoginPage.cs" /> <Compile Include="Pages\LoginPage.cs" />
<Compile Include="Pages\Settings\SettingsAddFolderPage.cs" /> <Compile Include="Pages\Settings\SettingsAddFolderPage.cs" />
<Compile Include="Pages\Vault\VaultAddCipherPage.cs" /> <Compile Include="Pages\Vault\VaultAddCipherPage.cs" />
<Compile Include="Pages\Vault\VaultViewLoginPage.cs" /> <Compile Include="Pages\Vault\VaultViewCipherPage.cs" />
<Compile Include="Pages\Vault\VaultEditLoginPage.cs" /> <Compile Include="Pages\Vault\VaultEditCipherPage.cs" />
<Compile Include="Pages\Vault\VaultListCiphersPage.cs" /> <Compile Include="Pages\Vault\VaultListCiphersPage.cs" />
<Compile Include="Services\PasswordGenerationService.cs" /> <Compile Include="Services\PasswordGenerationService.cs" />
<Compile Include="Utilities\Base32.cs" /> <Compile Include="Utilities\Base32.cs" />

View File

@ -9,7 +9,6 @@ using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Bit.App.Utilities; using Bit.App.Utilities;
using Plugin.Connectivity.Abstractions; using Plugin.Connectivity.Abstractions;
using System.Collections.Generic;
using Bit.App.Models; using Bit.App.Models;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -24,16 +23,16 @@ namespace Bit.App.Pages
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly ITokenService _tokenService; private readonly ITokenService _tokenService;
private readonly ICryptoService _cryptoService; private readonly ICryptoService _cryptoService;
private readonly string _loginId; private readonly string _cipherId;
private Cipher _login; private Cipher _cipher;
private byte[] _fileBytes; private byte[] _fileBytes;
private DateTime? _lastAction; private DateTime? _lastAction;
private bool _canUseAttachments = true; private bool _canUseAttachments = true;
public VaultAttachmentsPage(string loginId) public VaultAttachmentsPage(string cipherId)
: base(true) : base(true)
{ {
_loginId = loginId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_userDialogs = Resolver.Resolve<IUserDialogs>(); _userDialogs = Resolver.Resolve<IUserDialogs>();
@ -135,7 +134,7 @@ namespace Bit.App.Pages
var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () => var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () =>
{ {
if(_lastAction.LastActionWasRecent() || _login == null) if(_lastAction.LastActionWasRecent() || _cipher == null)
{ {
return; return;
} }
@ -162,7 +161,7 @@ namespace Bit.App.Pages
} }
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black);
var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_login, _fileBytes, FileLabel.Text); var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text);
_userDialogs.HideLoading(); _userDialogs.HideLoading();
@ -223,14 +222,14 @@ namespace Bit.App.Pages
private async Task LoadAttachmentsAsync() private async Task LoadAttachmentsAsync()
{ {
_login = await _cipherService.GetByIdAsync(_loginId); _cipher = await _cipherService.GetByIdAsync(_cipherId);
if(_login == null) if(_cipher == null)
{ {
await Navigation.PopForDeviceAsync(); await Navigation.PopForDeviceAsync();
return; return;
} }
var attachmentsToAdd = _login.Attachments var attachmentsToAdd = _cipher.Attachments
.Select(a => new VaultAttachmentsPageModel.Attachment(a)) .Select(a => new VaultAttachmentsPageModel.Attachment(a))
.OrderBy(s => s.Name); .OrderBy(s => s.Name);
PresentationAttchments.ResetWithRange(attachmentsToAdd); PresentationAttchments.ResetWithRange(attachmentsToAdd);
@ -268,7 +267,7 @@ namespace Bit.App.Pages
} }
_userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black);
var saveTask = await _cipherService.DeleteAttachmentAsync(_login, attachment.Id); var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id);
_userDialogs.HideLoading(); _userDialogs.HideLoading();
if(saveTask.Succeeded) if(saveTask.Succeeded)

View File

@ -240,7 +240,7 @@ namespace Bit.App.Pages
{ {
var buttons = new List<string> { AppResources.View, AppResources.Edit }; var buttons = new List<string> { AppResources.View, AppResources.Edit };
if(cipher.Type == Enums.CipherType.Login) if(cipher.Type == CipherType.Login)
{ {
if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) if(!string.IsNullOrWhiteSpace(cipher.Password.Value))
{ {
@ -251,7 +251,7 @@ namespace Bit.App.Pages
buttons.Add(AppResources.CopyUsername); buttons.Add(AppResources.CopyUsername);
} }
} }
else if(cipher.Type == Enums.CipherType.Card) else if(cipher.Type == CipherType.Card)
{ {
if(!string.IsNullOrWhiteSpace(cipher.CardNumber)) if(!string.IsNullOrWhiteSpace(cipher.CardNumber))
{ {
@ -267,12 +267,12 @@ namespace Bit.App.Pages
if(selection == AppResources.View) if(selection == AppResources.View)
{ {
var page = new VaultViewLoginPage(cipher.Id); var page = new VaultViewCipherPage(cipher.Id);
await Navigation.PushForDeviceAsync(page); await Navigation.PushForDeviceAsync(page);
} }
else if(selection == AppResources.Edit) else if(selection == AppResources.Edit)
{ {
var page = new VaultEditLoginPage(cipher.Id); var page = new VaultEditCipherPage(cipher.Id);
await Navigation.PushForDeviceAsync(page); await Navigation.PushForDeviceAsync(page);
} }
else if(selection == AppResources.CopyPassword) else if(selection == AppResources.CopyPassword)

View File

@ -20,14 +20,14 @@ namespace Bit.App.Pages
private readonly IUserDialogs _userDialogs; private readonly IUserDialogs _userDialogs;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly string _loginId; private readonly string _cipherId;
private Cipher _login; private Cipher _cipher;
private DateTime? _lastAction; private DateTime? _lastAction;
public VaultCustomFieldsPage(string loginId) public VaultCustomFieldsPage(string cipherId)
: base(true) : base(true)
{ {
_loginId = loginId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_userDialogs = Resolver.Resolve<IUserDialogs>(); _userDialogs = Resolver.Resolve<IUserDialogs>();
@ -66,7 +66,7 @@ namespace Bit.App.Pages
SaveToolbarItem = new ToolbarItem(AppResources.Save, null, async () => SaveToolbarItem = new ToolbarItem(AppResources.Save, null, async () =>
{ {
if(_lastAction.LastActionWasRecent() || _login == null) if(_lastAction.LastActionWasRecent() || _cipher == null)
{ {
return; return;
} }
@ -88,9 +88,9 @@ namespace Bit.App.Pages
fields.Add(new Field fields.Add(new Field
{ {
Name = string.IsNullOrWhiteSpace(entryCell.Label.Text) ? null : Name = string.IsNullOrWhiteSpace(entryCell.Label.Text) ? null :
entryCell.Label.Text.Encrypt(_login.OrganizationId), entryCell.Label.Text.Encrypt(_cipher.OrganizationId),
Value = string.IsNullOrWhiteSpace(entryCell.Entry.Text) ? null : Value = string.IsNullOrWhiteSpace(entryCell.Entry.Text) ? null :
entryCell.Entry.Text.Encrypt(_login.OrganizationId), entryCell.Entry.Text.Encrypt(_cipher.OrganizationId),
Type = entryCell.Entry.IsPassword ? FieldType.Hidden : FieldType.Text Type = entryCell.Entry.IsPassword ? FieldType.Hidden : FieldType.Text
}); });
} }
@ -100,21 +100,21 @@ namespace Bit.App.Pages
fields.Add(new Field fields.Add(new Field
{ {
Name = string.IsNullOrWhiteSpace(switchCell.Text) ? null : Name = string.IsNullOrWhiteSpace(switchCell.Text) ? null :
switchCell.Text.Encrypt(_login.OrganizationId), switchCell.Text.Encrypt(_cipher.OrganizationId),
Value = value.Encrypt(_login.OrganizationId), Value = value.Encrypt(_cipher.OrganizationId),
Type = FieldType.Boolean Type = FieldType.Boolean
}); });
} }
} }
_login.Fields = fields; _cipher.Fields = fields;
} }
else else
{ {
_login.Fields = null; _cipher.Fields = null;
} }
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black);
var saveTask = await _cipherService.SaveAsync(_login); var saveTask = await _cipherService.SaveAsync(_cipher);
_userDialogs.HideLoading(); _userDialogs.HideLoading();
@ -148,14 +148,14 @@ namespace Bit.App.Pages
{ {
base.OnAppearing(); base.OnAppearing();
_login = await _cipherService.GetByIdAsync(_loginId); _cipher = await _cipherService.GetByIdAsync(_cipherId);
if(_login == null) if(_cipher == null)
{ {
await Navigation.PopForDeviceAsync(); await Navigation.PopForDeviceAsync();
return; return;
} }
if(_login.Fields != null && _login.Fields.Any()) if(_cipher.Fields != null && _cipher.Fields.Any())
{ {
Content = Table; Content = Table;
ToolbarItems.Add(SaveToolbarItem); ToolbarItems.Add(SaveToolbarItem);
@ -164,10 +164,10 @@ namespace Bit.App.Pages
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }
foreach(var field in _login.Fields) foreach(var field in _cipher.Fields)
{ {
var label = field.Name?.Decrypt(_login.OrganizationId) ?? string.Empty; var label = field.Name?.Decrypt(_cipher.OrganizationId) ?? string.Empty;
var value = field.Value?.Decrypt(_login.OrganizationId); var value = field.Value?.Decrypt(_cipher.OrganizationId);
switch(field.Type) switch(field.Type)
{ {
case FieldType.Text: case FieldType.Text:

View File

@ -12,9 +12,9 @@ using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
public class VaultEditLoginPage : ExtendedContentPage public class VaultEditCipherPage : ExtendedContentPage
{ {
private readonly string _loginId; private readonly string _cipherId;
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IUserDialogs _userDialogs; private readonly IUserDialogs _userDialogs;
@ -23,9 +23,9 @@ namespace Bit.App.Pages
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
private DateTime? _lastAction; private DateTime? _lastAction;
public VaultEditLoginPage(string loginId) public VaultEditCipherPage(string cipherId)
{ {
_loginId = loginId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_folderService = Resolver.Resolve<IFolderService>(); _folderService = Resolver.Resolve<IFolderService>();
_userDialogs = Resolver.Resolve<IUserDialogs>(); _userDialogs = Resolver.Resolve<IUserDialogs>();
@ -50,7 +50,7 @@ namespace Bit.App.Pages
private void Init() private void Init()
{ {
var cipher = _cipherService.GetByIdAsync(_loginId).GetAwaiter().GetResult(); var cipher = _cipherService.GetByIdAsync(_cipherId).GetAwaiter().GetResult();
if(cipher == null) if(cipher == null)
{ {
// TODO: handle error. navigate back? should never happen... // TODO: handle error. navigate back? should never happen...
@ -385,13 +385,13 @@ namespace Bit.App.Pages
private async void AttachmentsCell_Tapped(object sender, EventArgs e) private async void AttachmentsCell_Tapped(object sender, EventArgs e)
{ {
var page = new ExtendedNavigationPage(new VaultAttachmentsPage(_loginId)); var page = new ExtendedNavigationPage(new VaultAttachmentsPage(_cipherId));
await Navigation.PushModalAsync(page); await Navigation.PushModalAsync(page);
} }
private async void CustomFieldsCell_Tapped(object sender, EventArgs e) private async void CustomFieldsCell_Tapped(object sender, EventArgs e)
{ {
var page = new ExtendedNavigationPage(new VaultCustomFieldsPage(_loginId)); var page = new ExtendedNavigationPage(new VaultCustomFieldsPage(_cipherId));
await Navigation.PushModalAsync(page); await Navigation.PushModalAsync(page);
} }
@ -409,7 +409,7 @@ namespace Bit.App.Pages
} }
_userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black);
var deleteTask = await _cipherService.DeleteAsync(_loginId); var deleteTask = await _cipherService.DeleteAsync(_cipherId);
_userDialogs.HideLoading(); _userDialogs.HideLoading();
if(deleteTask.Succeeded) if(deleteTask.Succeeded)

View File

@ -398,7 +398,7 @@ namespace Bit.App.Pages
if(selection == AppResources.View || string.IsNullOrWhiteSpace(Uri)) if(selection == AppResources.View || string.IsNullOrWhiteSpace(Uri))
{ {
var page = new VaultViewLoginPage(cipher.Id); var page = new VaultViewCipherPage(cipher.Id);
await Navigation.PushForDeviceAsync(page); await Navigation.PushForDeviceAsync(page);
} }
else if(selection == AppResources.Autofill) else if(selection == AppResources.Autofill)
@ -421,7 +421,7 @@ namespace Bit.App.Pages
{ {
var buttons = new List<string> { AppResources.View, AppResources.Edit }; var buttons = new List<string> { AppResources.View, AppResources.Edit };
if(cipher.Type == Enums.CipherType.Login) if(cipher.Type == CipherType.Login)
{ {
if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) if(!string.IsNullOrWhiteSpace(cipher.Password.Value))
{ {
@ -437,7 +437,7 @@ namespace Bit.App.Pages
buttons.Add(AppResources.GoToWebsite); buttons.Add(AppResources.GoToWebsite);
} }
} }
else if(cipher.Type == Enums.CipherType.Card) else if(cipher.Type == CipherType.Card)
{ {
if(!string.IsNullOrWhiteSpace(cipher.CardNumber)) if(!string.IsNullOrWhiteSpace(cipher.CardNumber))
{ {
@ -453,12 +453,12 @@ namespace Bit.App.Pages
if(selection == AppResources.View) if(selection == AppResources.View)
{ {
var page = new VaultViewLoginPage(cipher.Id); var page = new VaultViewCipherPage(cipher.Id);
await Navigation.PushForDeviceAsync(page); await Navigation.PushForDeviceAsync(page);
} }
else if(selection == AppResources.Edit) else if(selection == AppResources.Edit)
{ {
var page = new VaultEditLoginPage(cipher.Id); var page = new VaultEditCipherPage(cipher.Id);
await Navigation.PushForDeviceAsync(page); await Navigation.PushForDeviceAsync(page);
} }
else if(selection == AppResources.CopyPassword) else if(selection == AppResources.CopyPassword)

View File

@ -15,7 +15,7 @@ using Bit.App.Enums;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
public class VaultViewLoginPage : ExtendedContentPage public class VaultViewCipherPage : ExtendedContentPage
{ {
private readonly string _loginId; private readonly string _loginId;
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
@ -24,7 +24,7 @@ namespace Bit.App.Pages
private readonly ITokenService _tokenService; private readonly ITokenService _tokenService;
private bool _pageDisappeared = true; private bool _pageDisappeared = true;
public VaultViewLoginPage(string loginId) public VaultViewCipherPage(string loginId)
{ {
_loginId = loginId; _loginId = loginId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
@ -372,10 +372,10 @@ namespace Bit.App.Pages
private class EditLoginToolBarItem : ExtendedToolbarItem private class EditLoginToolBarItem : ExtendedToolbarItem
{ {
private readonly VaultViewLoginPage _page; private readonly VaultViewCipherPage _page;
private readonly string _loginId; private readonly string _loginId;
public EditLoginToolBarItem(VaultViewLoginPage page, string loginId) public EditLoginToolBarItem(VaultViewCipherPage page, string loginId)
{ {
_page = page; _page = page;
_loginId = loginId; _loginId = loginId;
@ -385,7 +385,7 @@ namespace Bit.App.Pages
private async Task ClickedItem() private async Task ClickedItem()
{ {
var page = new VaultEditLoginPage(_loginId); var page = new VaultEditCipherPage(_loginId);
await _page.Navigation.PushForDeviceAsync(page); await _page.Navigation.PushForDeviceAsync(page);
} }
} }
@ -422,19 +422,19 @@ namespace Bit.App.Pages
public class FieldViewCell : LabeledValueCell public class FieldViewCell : LabeledValueCell
{ {
public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field) public FieldViewCell(VaultViewCipherPage page, VaultViewLoginPageModel.Field field)
: base(field.Name, field.Value == "true" ? "✓" : "-") : base(field.Name, field.Value == "true" ? "✓" : "-")
{ {
Init(page, field, null); Init(page, field, null);
} }
public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, bool? a) public FieldViewCell(VaultViewCipherPage page, VaultViewLoginPageModel.Field field, bool? a)
: base(field.Name, field.Value, AppResources.Copy) : base(field.Name, field.Value, AppResources.Copy)
{ {
Init(page, field, Button1); Init(page, field, Button1);
} }
public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, bool? a, bool? b) public FieldViewCell(VaultViewCipherPage page, VaultViewLoginPageModel.Field field, bool? a, bool? b)
: base(field.Name, field.MaskedValue, string.Empty, AppResources.Copy) : base(field.Name, field.MaskedValue, string.Empty, AppResources.Copy)
{ {
Value.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Value.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular",
@ -464,7 +464,7 @@ namespace Bit.App.Pages
Init(page, field, Button2); Init(page, field, Button2);
} }
private void Init(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, ExtendedButton copyButton) private void Init(VaultViewCipherPage page, VaultViewLoginPageModel.Field field, ExtendedButton copyButton)
{ {
Value.LineBreakMode = LineBreakMode.WordWrap; Value.LineBreakMode = LineBreakMode.WordWrap;
if(copyButton != null) if(copyButton != null)