diff --git a/src/App/Pages/Vault/AddEditPage.xaml b/src/App/Pages/Vault/AddEditPage.xaml index 8d0f1c37e..44c3fbcce 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml +++ b/src/App/Pages/Vault/AddEditPage.xaml @@ -112,9 +112,11 @@ StyleClass="box-value" Grid.Row="1" Grid.Column="0" + Grid.ColumnSpan="{Binding PasswordFieldColSpan}" IsPassword="{Binding ShowPassword, Converter={StaticResource inverseBool}}" IsSpellCheckEnabled="False" - IsTextPredictionEnabled="False" /> + IsTextPredictionEnabled="False" + IsEnabled="{Binding Cipher.ViewPassword}"/> + AutomationProperties.Name="{u:I18n CheckPassword}" + IsVisible="{Binding Cipher.ViewPassword}" /> + AutomationProperties.Name="{u:I18n ToggleVisibility}" + IsVisible="{Binding Cipher.ViewPassword}" /> + AutomationProperties.Name="{u:I18n GeneratePassword}" + IsVisible="{Binding Cipher.ViewPassword}" /> @@ -163,9 +168,12 @@ Text="{Binding Cipher.Login.Totp}" IsSpellCheckEnabled="False" IsTextPredictionEnabled="False" + IsPassword="{Binding Cipher.ViewPassword, Converter={StaticResource inverseBool}}" + IsEnabled="{Binding Cipher.ViewPassword}" StyleClass="box-value" Grid.Row="1" - Grid.Column="0" /> + Grid.Column="0" + Grid.ColumnSpan="{Binding TotpColumnSpan}" /> @@ -562,6 +571,7 @@ Grid.Column="0" IsVisible="{Binding IsHiddenType}" IsPassword="{Binding ShowHiddenValue, Converter={StaticResource inverseBool}}" + IsEnabled="{Binding ShowViewHidden}" IsSpellCheckEnabled="False" IsTextPredictionEnabled="False"> @@ -582,7 +592,7 @@ StyleClass="box-row-button, box-row-button-platform" Text="{Binding ShowHiddenValueIcon}" Command="{Binding ToggleHiddenValueCommand}" - IsVisible="{Binding IsHiddenType}" + IsVisible="{Binding ShowViewHidden}" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs index bcc331e83..34a44b04c 100644 --- a/src/App/Pages/Vault/AddEditPageViewModel.cs +++ b/src/App/Pages/Vault/AddEditPageViewModel.cs @@ -274,6 +274,8 @@ namespace Bit.App.Pages public bool ShowAttachments => Cipher.HasAttachments; public string ShowPasswordIcon => ShowPassword ? "" : ""; public string ShowCardCodeIcon => ShowCardCode ? "" : ""; + public int PasswordFieldColSpan => Cipher.ViewPassword ? 1 : 4; + public int TotpColumnSpan => Cipher.ViewPassword ? 1 : 2; public void Init() { @@ -631,7 +633,8 @@ namespace Bit.App.Pages Fields.Add(new AddEditPageFieldViewModel(Cipher, new FieldView { Type = type, - Name = string.IsNullOrWhiteSpace(name) ? null : name + Name = string.IsNullOrWhiteSpace(name) ? null : name, + NewField = true, })); } } @@ -818,6 +821,7 @@ namespace Bit.App.Pages public bool IsTextType => _field.Type == FieldType.Text; public bool IsBooleanType => _field.Type == FieldType.Boolean; public bool IsHiddenType => _field.Type == FieldType.Hidden; + public bool ShowViewHidden => IsHiddenType && (_cipher.ViewPassword || _field.NewField); public void ToggleHiddenValue() { diff --git a/src/App/Pages/Vault/ViewPage.xaml b/src/App/Pages/Vault/ViewPage.xaml index 1891576a6..5a54e9d9c 100644 --- a/src/App/Pages/Vault/ViewPage.xaml +++ b/src/App/Pages/Vault/ViewPage.xaml @@ -134,7 +134,8 @@ Grid.Column="1" Grid.RowSpan="2" AutomationProperties.IsInAccessibleTree="True" - AutomationProperties.Name="{u:I18n CheckPassword}" /> + AutomationProperties.Name="{u:I18n CheckPassword}" + IsVisible="{Binding Cipher.ViewPassword}" /> + AutomationProperties.Name="{u:I18n ToggleVisibility}" + IsVisible="{Binding Cipher.ViewPassword}" /> + AutomationProperties.Name="{u:I18n CopyPassword}" + IsVisible="{Binding Cipher.ViewPassword}" /> @@ -570,7 +573,7 @@ StyleClass="box-row-button, box-row-button-platform" Text="{Binding ShowHiddenValueIcon}" Command="{Binding ToggleHiddenValueCommand}" - IsVisible="{Binding IsHiddenType}" + IsVisible="{Binding ShowViewHidden}" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" diff --git a/src/App/Pages/Vault/ViewPageViewModel.cs b/src/App/Pages/Vault/ViewPageViewModel.cs index 3e49ea308..73314c558 100644 --- a/src/App/Pages/Vault/ViewPageViewModel.cs +++ b/src/App/Pages/Vault/ViewPageViewModel.cs @@ -684,8 +684,9 @@ namespace Bit.App.Pages public bool IsTextType => _field.Type == Core.Enums.FieldType.Text; public bool IsBooleanType => _field.Type == Core.Enums.FieldType.Boolean; public bool IsHiddenType => _field.Type == Core.Enums.FieldType.Hidden; + public bool ShowViewHidden => IsHiddenType && _cipher.ViewPassword; public bool ShowCopyButton => _field.Type != Core.Enums.FieldType.Boolean && - !string.IsNullOrWhiteSpace(_field.Value); + !string.IsNullOrWhiteSpace(_field.Value) && !(IsHiddenType && !_cipher.ViewPassword); public void ToggleHiddenValue() { diff --git a/src/App/Utilities/AppHelpers.cs b/src/App/Utilities/AppHelpers.cs index a1e782982..3dd8f0149 100644 --- a/src/App/Utilities/AppHelpers.cs +++ b/src/App/Utilities/AppHelpers.cs @@ -30,7 +30,7 @@ namespace Bit.App.Utilities { options.Add(AppResources.CopyUsername); } - if (!string.IsNullOrWhiteSpace(cipher.Login.Password)) + if (!string.IsNullOrWhiteSpace(cipher.Login.Password) && cipher.ViewPassword) { options.Add(AppResources.CopyPassword); } diff --git a/src/Core/Models/Data/CipherData.cs b/src/Core/Models/Data/CipherData.cs index 636e17963..c034833b2 100644 --- a/src/Core/Models/Data/CipherData.cs +++ b/src/Core/Models/Data/CipherData.cs @@ -16,6 +16,7 @@ namespace Bit.Core.Models.Data FolderId = response.FolderId; UserId = userId; Edit = response.Edit; + ViewPassword = response.ViewPassword; OrganizationUseTotp = response.OrganizationUseTotp; Favorite = response.Favorite; RevisionDate = response.RevisionDate; @@ -53,6 +54,7 @@ namespace Bit.Core.Models.Data public string FolderId { get; set; } public string UserId { get; set; } public bool Edit { get; set; } + public bool ViewPassword { get; set; } public bool OrganizationUseTotp { get; set; } public bool Favorite { get; set; } public DateTime RevisionDate { get; set; } diff --git a/src/Core/Models/Domain/Cipher.cs b/src/Core/Models/Domain/Cipher.cs index fce6b6d65..af4228be0 100644 --- a/src/Core/Models/Domain/Cipher.cs +++ b/src/Core/Models/Domain/Cipher.cs @@ -26,6 +26,7 @@ namespace Bit.Core.Models.Domain Favorite = obj.Favorite; OrganizationUseTotp = obj.OrganizationUseTotp; Edit = obj.Edit; + ViewPassword = obj.ViewPassword; RevisionDate = obj.RevisionDate; CollectionIds = obj.CollectionIds != null ? new HashSet(obj.CollectionIds) : null; LocalData = localData; @@ -63,6 +64,7 @@ namespace Bit.Core.Models.Domain public bool Favorite { get; set; } public bool OrganizationUseTotp { get; set; } public bool Edit { get; set; } + public bool ViewPassword { get; set; } public DateTime RevisionDate { get; set; } public Dictionary LocalData { get; set; } public Login Login { get; set; } diff --git a/src/Core/Models/Response/CipherResponse.cs b/src/Core/Models/Response/CipherResponse.cs index d6be67785..177104827 100644 --- a/src/Core/Models/Response/CipherResponse.cs +++ b/src/Core/Models/Response/CipherResponse.cs @@ -19,6 +19,7 @@ namespace Bit.Core.Models.Response public SecureNoteApi SecureNote { get; set; } public bool Favorite { get; set; } public bool Edit { get; set; } + public bool ViewPassword { get; set; } = true; // Fallback for old server versions public bool OrganizationUseTotp { get; set; } public DateTime RevisionDate { get; set; } public List Attachments { get; set; } diff --git a/src/Core/Models/View/CipherView.cs b/src/Core/Models/View/CipherView.cs index 44584f381..da0f4a829 100644 --- a/src/Core/Models/View/CipherView.cs +++ b/src/Core/Models/View/CipherView.cs @@ -18,6 +18,7 @@ namespace Bit.Core.Models.View Favorite = c.Favorite; OrganizationUseTotp = c.OrganizationUseTotp; Edit = c.Edit; + ViewPassword = c.ViewPassword; Type = c.Type; LocalData = c.LocalData; CollectionIds = c.CollectionIds; @@ -34,6 +35,7 @@ namespace Bit.Core.Models.View public bool Favorite { get; set; } public bool OrganizationUseTotp { get; set; } public bool Edit { get; set; } + public bool ViewPassword { get; set; } public Dictionary LocalData { get; set; } public LoginView Login { get; set; } public IdentityView Identity { get; set; } diff --git a/src/Core/Models/View/FieldView.cs b/src/Core/Models/View/FieldView.cs index 5fa93a68f..307112564 100644 --- a/src/Core/Models/View/FieldView.cs +++ b/src/Core/Models/View/FieldView.cs @@ -16,5 +16,6 @@ namespace Bit.Core.Models.View public string Value { get; set; } public FieldType Type { get; set; } public string MaskedValue => Value != null ? "••••••••" : null; + public bool NewField { get; set; } } }