yubikey fixes for ios

This commit is contained in:
Kyle Spearrin 2019-07-06 21:59:13 -04:00
parent 066b3aba5b
commit eca4777b99
5 changed files with 23 additions and 4 deletions

View file

@ -124,6 +124,10 @@
IsVisible="{Binding EmailMethod}" IsVisible="{Binding EmailMethod}"
Clicked="ResendEmail_Clicked" Clicked="ResendEmail_Clicked"
Margin="10, 0"></Button> Margin="10, 0"></Button>
<Button Text="{u:I18n TryAgain}"
IsVisible="{Binding ShowTryAgain}"
Clicked="TryAgain_Clicked"
Margin="10, 0"></Button>
<Button Text="{u:I18n UseAnotherTwoStepMethod}" <Button Text="{u:I18n UseAnotherTwoStepMethod}"
Clicked="Methods_Clicked" Clicked="Methods_Clicked"
Margin="10, 0"></Button> Margin="10, 0"></Button>

View file

@ -55,11 +55,12 @@ namespace Bit.App.Pages
{ {
if(message.Command == "gotYubiKeyOTP") if(message.Command == "gotYubiKeyOTP")
{ {
if(_vm.YubikeyMethod) var token = (string)message.Data;
if(_vm.YubikeyMethod && !string.IsNullOrWhiteSpace(token) && !token.Contains(" "))
{ {
Device.BeginInvokeOnMainThread(async () => Device.BeginInvokeOnMainThread(async () =>
{ {
_vm.Token = (string)message.Data; _vm.Token = token;
await _vm.SubmitAsync(); await _vm.SubmitAsync();
}); });
} }
@ -138,5 +139,16 @@ namespace Bit.App.Pages
await Navigation.PopModalAsync(); await Navigation.PopModalAsync();
} }
} }
private void TryAgain_Clicked(object sender, EventArgs e)
{
if(DoOnce())
{
if(_vm.YubikeyMethod)
{
_messagingService.Send("listenYubiKeyOTP", true);
}
}
}
} }
} }

View file

@ -69,6 +69,8 @@ namespace Bit.App.Pages
public bool TotpMethod => AuthenticatorMethod || EmailMethod; public bool TotpMethod => AuthenticatorMethod || EmailMethod;
public bool ShowTryAgain => YubikeyMethod && Device.RuntimePlatform == Device.iOS;
public string YubikeyInstruction => Device.RuntimePlatform == Device.iOS ? AppResources.YubiKeyInstructionIos : public string YubikeyInstruction => Device.RuntimePlatform == Device.iOS ? AppResources.YubiKeyInstructionIos :
AppResources.YubiKeyInstruction; AppResources.YubiKeyInstruction;
@ -82,6 +84,7 @@ namespace Bit.App.Pages
nameof(YubikeyMethod), nameof(YubikeyMethod),
nameof(AuthenticatorMethod), nameof(AuthenticatorMethod),
nameof(TotpMethod), nameof(TotpMethod),
nameof(ShowTryAgain),
}); });
} }
public Command SubmitCommand { get; } public Command SubmitCommand { get; }

View file

@ -3580,7 +3580,7 @@ namespace Bit.App.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Try Again. /// Looks up a localized string similar to Try again.
/// </summary> /// </summary>
public static string TryAgain { public static string TryAgain {
get { get {

View file

@ -1249,7 +1249,7 @@
<value>Hold your Yubikey near the top of the device.</value> <value>Hold your Yubikey near the top of the device.</value>
</data> </data>
<data name="TryAgain" xml:space="preserve"> <data name="TryAgain" xml:space="preserve">
<value>Try Again</value> <value>Try again</value>
</data> </data>
<data name="YubiKeyInstructionIos" xml:space="preserve"> <data name="YubiKeyInstructionIos" xml:space="preserve">
<value>To continue, hold your YubiKey NEO against the back of the device.</value> <value>To continue, hold your YubiKey NEO against the back of the device.</value>