1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-23 11:45:38 +01:00

clearup yubikey reading on ios

This commit is contained in:
Kyle Spearrin 2018-05-24 15:34:09 -04:00
parent d3003efe72
commit d3646e10a5
4 changed files with 24 additions and 8 deletions

View File

@ -1590,6 +1590,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Hold your Yubikey near the top of the device..
/// </summary>
public static string HoldYubikeyNearTop {
get {
return ResourceManager.GetString("HoldYubikeyNearTop", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Host.
/// </summary>

View File

@ -1293,4 +1293,7 @@
<value>Organization</value>
<comment>An entity of multiple related people (ex. a team or business organization).</comment>
</data>
<data name="HoldYubikeyNearTop" xml:space="preserve">
<value>Hold your Yubikey near the top of the device.</value>
</data>
</root>

View File

@ -21,6 +21,7 @@ using FFImageLoading.Forms.Touch;
using SimpleInjector;
using XLabs.Ioc.SimpleInjectorContainer;
using CoreNFC;
using Bit.App.Resources;
namespace Bit.iOS
{
@ -120,21 +121,26 @@ namespace Bit.iOS
if(listen)
{
var del = new NFCReaderDelegate((success, message) =>
_nfcSession?.InvalidateSession();
_nfcSession?.Dispose();
_nfcSession = null;
_nfcSession = new NFCNdefReaderSession(new NFCReaderDelegate((success, message) =>
{
Debug.WriteLine((success ? "SUCCESS! " : "ERROR! ") + message);
if(success)
{
MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message);
Device.BeginInvokeOnMainThread(() =>
{
MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message);
});
}
});
_nfcSession = new NFCNdefReaderSession(del, null, true);
}), null, true);
_nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop;
_nfcSession.BeginSession();
}
else
{
_nfcSession?.InvalidateSession();
_nfcSession?.Dispose();
_nfcSession = null;
}
});

View File

@ -34,12 +34,10 @@ namespace Bit.iOS
foreach(var result in results)
{
Debug.WriteLine("READ TAG: " + result);
var matches = _otpPattern.Matches(result);
if(matches.Count > 0 && matches[0].Groups.Count > 1)
{
var otp = matches[0].Groups[1].ToString();
Debug.WriteLine("TAG IS MATCH: " + otp);
_callback.Invoke(true, otp);
return;
}