mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-22 11:35:21 +01:00
[EC-341] Fix show alternative 2FA on iOS extensions (#2011)
* EC-341 Fix show alternative 2FA on iOS extensions * EC-341 Fix iOS.Core.csproj reference
This commit is contained in:
parent
2c8406d0ad
commit
ae4e8e2d8e
@ -17,15 +17,19 @@
|
||||
<ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1"
|
||||
x:Name="_cancelItem" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<u:IsNullConverter x:Key="isNull" />
|
||||
<ToolbarItem Icon="more_vert.png" Clicked="More_Clicked" Order="Primary"
|
||||
x:Name="_moreItem" x:Key="moreItem"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Options}" />
|
||||
<ToolbarItem
|
||||
x:Name="_moreItem"
|
||||
x:Key="moreItem"
|
||||
Icon="more_vert.png"
|
||||
Order="Primary"
|
||||
Command="{Binding MoreCommand}"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Options}" />
|
||||
<ToolbarItem Text="{u:I18n UseAnotherTwoStepMethod}"
|
||||
Clicked="Methods_Clicked"
|
||||
Order="Secondary"
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Resources;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities;
|
||||
@ -137,21 +136,6 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private async void More_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!DoOnce())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selection = await DisplayActionSheet(AppResources.Options, AppResources.Cancel, null, AppResources.UseAnotherTwoStepMethod);
|
||||
|
||||
if (selection == AppResources.UseAnotherTwoStepMethod)
|
||||
{
|
||||
await _vm.AnotherMethodAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async void ResendEmail_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if (DoOnce())
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Resources;
|
||||
using Bit.App.Utilities;
|
||||
@ -12,6 +13,7 @@ using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Request;
|
||||
using Bit.Core.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Xamarin.CommunityToolkit.ObjectModel;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
@ -30,6 +32,7 @@ namespace Bit.App.Pages
|
||||
private readonly IStateService _stateService;
|
||||
private readonly II18nService _i18nService;
|
||||
private readonly IAppIdService _appIdService;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private TwoFactorProviderType? _selectedProviderType;
|
||||
private string _totpInstruction;
|
||||
@ -51,9 +54,11 @@ namespace Bit.App.Pages
|
||||
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
|
||||
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService");
|
||||
_appIdService = ServiceContainer.Resolve<IAppIdService>("appIdService");
|
||||
_logger = ServiceContainer.Resolve<ILogger>();
|
||||
|
||||
PageTitle = AppResources.TwoStepLogin;
|
||||
SubmitCommand = new Command(async () => await SubmitAsync());
|
||||
MoreCommand = new AsyncCommand(MoreAsync, onException: _logger.Exception, allowsMultipleExecutions: false);
|
||||
}
|
||||
|
||||
public string TotpInstruction
|
||||
@ -111,6 +116,7 @@ namespace Bit.App.Pages
|
||||
});
|
||||
}
|
||||
public Command SubmitCommand { get; }
|
||||
public ICommand MoreCommand { get; }
|
||||
public Action TwoFactorAuthSuccessAction { get; set; }
|
||||
public Action StartSetPasswordAction { get; set; }
|
||||
public Action CloseAction { get; set; }
|
||||
@ -337,6 +343,15 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private async Task MoreAsync()
|
||||
{
|
||||
var selection = await _deviceActionService.DisplayActionSheetAsync(AppResources.Options, AppResources.Cancel, null, AppResources.UseAnotherTwoStepMethod);
|
||||
if (selection == AppResources.UseAnotherTwoStepMethod)
|
||||
{
|
||||
await AnotherMethodAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AnotherMethodAsync()
|
||||
{
|
||||
var supportedProviders = _authService.GetSupportedTwoFactorProviders();
|
||||
|
@ -18,6 +18,7 @@ using CoreNFC;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
namespace Bit.iOS.Autofill
|
||||
{
|
||||
|
@ -253,6 +253,17 @@
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\logo_white%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert.png">
|
||||
<Link>Resources\more_vert.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert%402x.png">
|
||||
<Link>Resources\more_vert%402x.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert%403x.png">
|
||||
<Link>Resources\more_vert%403x.png</Link>
|
||||
</BundleResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AppCenter.Crashes">
|
||||
<Version>4.4.0</Version>
|
||||
|
@ -84,6 +84,12 @@ namespace Bit.iOS.Core.Services
|
||||
HideLoadingAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
var vc = GetPresentedViewController();
|
||||
if (vc is null)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var result = new TaskCompletionSource<int>();
|
||||
|
||||
var loadingIndicator = new UIActivityIndicatorView(new CGRect(10, 5, 50, 50));
|
||||
@ -96,8 +102,7 @@ namespace Bit.iOS.Core.Services
|
||||
_progressAlert.View.TintColor = UIColor.Black;
|
||||
_progressAlert.View.Add(loadingIndicator);
|
||||
|
||||
var vc = GetPresentedViewController();
|
||||
vc?.PresentViewController(_progressAlert, false, () => result.TrySetResult(0));
|
||||
vc.PresentViewController(_progressAlert, false, () => result.TrySetResult(0));
|
||||
return result.Task;
|
||||
}
|
||||
|
||||
@ -205,6 +210,12 @@ namespace Bit.iOS.Core.Services
|
||||
string text = null, string okButtonText = null, string cancelButtonText = null,
|
||||
bool numericKeyboard = false, bool autofocus = true, bool password = false)
|
||||
{
|
||||
var vc = GetPresentedViewController();
|
||||
if (vc is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = new TaskCompletionSource<string>();
|
||||
var alert = UIAlertController.Create(title ?? string.Empty, description, UIAlertControllerStyle.Alert);
|
||||
UITextField input = null;
|
||||
@ -234,8 +245,7 @@ namespace Bit.iOS.Core.Services
|
||||
input.KeyboardAppearance = UIKeyboardAppearance.Dark;
|
||||
}
|
||||
});
|
||||
var vc = GetPresentedViewController();
|
||||
vc?.PresentViewController(alert, true, null);
|
||||
vc.PresentViewController(alert, true, null);
|
||||
return result.Task;
|
||||
}
|
||||
|
||||
@ -312,6 +322,12 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
public Task<string> DisplayAlertAsync(string title, string message, string cancel, params string[] buttons)
|
||||
{
|
||||
var vc = GetPresentedViewController();
|
||||
if (vc is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = new TaskCompletionSource<string>();
|
||||
var alert = UIAlertController.Create(title ?? string.Empty, message, UIAlertControllerStyle.Alert);
|
||||
if (!string.IsNullOrWhiteSpace(cancel))
|
||||
@ -328,8 +344,7 @@ namespace Bit.iOS.Core.Services
|
||||
result.TrySetResult(button);
|
||||
}));
|
||||
}
|
||||
var vc = GetPresentedViewController();
|
||||
vc?.PresentViewController(alert, true, null);
|
||||
vc.PresentViewController(alert, true, null);
|
||||
return result.Task;
|
||||
}
|
||||
|
||||
@ -340,8 +355,12 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
return app.MainPage.DisplayActionSheet(title, cancel, destruction, buttons);
|
||||
}
|
||||
var result = new TaskCompletionSource<string>();
|
||||
var vc = GetPresentedViewController();
|
||||
if (vc is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = new TaskCompletionSource<string>();
|
||||
var sheet = UIAlertController.Create(title, null, UIAlertControllerStyle.ActionSheet);
|
||||
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
|
||||
{
|
||||
|
@ -230,6 +230,15 @@
|
||||
<BundleResource Include="Resources\yubikey.png" />
|
||||
<BundleResource Include="Resources\yubikey%403x.png" />
|
||||
<BundleResource Include="Resources\yubikey%402x.png" />
|
||||
<BundleResource Include="..\iOS\Resources\more_vert.png">
|
||||
<Link>Resources\more_vert.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert%402x.png">
|
||||
<Link>Resources\more_vert%402x.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert%403x.png">
|
||||
<Link>Resources\more_vert%403x.png</Link>
|
||||
</BundleResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AppCenter.Crashes">
|
||||
|
@ -227,6 +227,15 @@
|
||||
<BundleResource Include="..\iOS\Resources\logo.png">
|
||||
<Link>Resources\logo.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert.png">
|
||||
<Link>Resources\more_vert.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert%402x.png">
|
||||
<Link>Resources\more_vert%402x.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\more_vert%403x.png">
|
||||
<Link>Resources\more_vert%403x.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="..\iOS\Resources\bwi-font.ttf">
|
||||
<Link>Resources\bwi-font.ttf</Link>
|
||||
</BundleResource>
|
||||
|
Loading…
Reference in New Issue
Block a user