PM-3227 Avoid clone on discoverable passkeys. (#2648)

This commit is contained in:
Federico Maccaroni 2023-07-27 18:35:09 -03:00 committed by GitHub
parent 9eda015371
commit 375718f945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View file

@ -204,7 +204,7 @@ namespace Bit.App.Pages
} }
} }
private async void More_Clicked(object sender, System.EventArgs e) private async void More_Clicked(object sender, EventArgs e)
{ {
if (!DoOnce()) if (!DoOnce())
{ {
@ -214,7 +214,11 @@ namespace Bit.App.Pages
var options = new List<string> { AppResources.Attachments }; var options = new List<string> { AppResources.Attachments };
if (_vm.Cipher.OrganizationId == null) if (_vm.Cipher.OrganizationId == null)
{ {
options.Add(AppResources.Clone); if (_vm.CanClone)
{
options.Add(AppResources.Clone);
}
options.Add(AppResources.MoveToOrganization); options.Add(AppResources.MoveToOrganization);
} }
else else
@ -288,13 +292,13 @@ namespace Bit.App.Pages
{ {
ToolbarItems.Remove(_collectionsItem); ToolbarItems.Remove(_collectionsItem);
} }
if (_vm.Cipher.Type != Core.Enums.CipherType.Fido2Key && !ToolbarItems.Contains(_cloneItem)) if (_vm.CanClone && !ToolbarItems.Contains(_cloneItem))
{ {
ToolbarItems.Insert(1, _cloneItem); ToolbarItems.Insert(1, _cloneItem);
} }
if (!ToolbarItems.Contains(_shareItem)) if (!ToolbarItems.Contains(_shareItem))
{ {
ToolbarItems.Insert(_vm.Cipher.Type == Core.Enums.CipherType.Fido2Key ? 1 : 2, _shareItem); ToolbarItems.Insert(_vm.CanClone ? 2 : 1, _shareItem);
} }
} }
else else

View file

@ -249,6 +249,7 @@ namespace Bit.App.Pages
public double TotpProgress => string.IsNullOrEmpty(TotpSec) ? 0 : double.Parse(TotpSec) * 100 / _totpInterval; public double TotpProgress => string.IsNullOrEmpty(TotpSec) ? 0 : double.Parse(TotpSec) * 100 / _totpInterval;
public bool IsDeleted => Cipher.IsDeleted; public bool IsDeleted => Cipher.IsDeleted;
public bool CanEdit => !Cipher.IsDeleted; public bool CanEdit => !Cipher.IsDeleted;
public bool CanClone => Cipher.IsClonable;
public async Task<bool> LoadAsync(Action finishedLoadingAction = null) public async Task<bool> LoadAsync(Action finishedLoadingAction = null)
{ {
@ -707,6 +708,12 @@ namespace Bit.App.Pages
private async Task<bool> CanCloneAsync() private async Task<bool> CanCloneAsync()
{ {
if (Cipher.Type == CipherType.Fido2Key)
{
await _platformUtilsService.ShowDialogAsync(AppResources.PasskeyWillNotBeCopied);
return false;
}
if (Cipher.Type == CipherType.Login && Cipher.Login?.Fido2Key != null) if (Cipher.Type == CipherType.Login && Cipher.Login?.Fido2Key != null)
{ {
return await _platformUtilsService.ShowDialogAsync(AppResources.ThePasskeyWillNotBeCopiedToTheClonedItemDoYouWantToContinueCloningThisItem, AppResources.PasskeyWillNotBeCopied, AppResources.Yes, AppResources.No); return await _platformUtilsService.ShowDialogAsync(AppResources.ThePasskeyWillNotBeCopiedToTheClonedItemDoYouWantToContinueCloningThisItem, AppResources.PasskeyWillNotBeCopied, AppResources.Yes, AppResources.No);

View file

@ -120,5 +120,7 @@ namespace Bit.Core.Models.View
public bool CanLaunch => Login?.CanLaunch == true || Fido2Key?.CanLaunch == true; public bool CanLaunch => Login?.CanLaunch == true || Fido2Key?.CanLaunch == true;
public string LaunchUri => Login?.LaunchUri ?? Fido2Key?.LaunchUri; public string LaunchUri => Login?.LaunchUri ?? Fido2Key?.LaunchUri;
public bool IsClonable => OrganizationId is null && Type != CipherType.Fido2Key;
} }
} }