setup 2fa methods page

This commit is contained in:
Kyle Spearrin 2017-06-27 17:10:40 -04:00
parent ae35bd2047
commit e2a3e55a17
3 changed files with 147 additions and 3 deletions

View file

@ -134,6 +134,7 @@
<Compile Include="Pages\HomePage.cs" />
<Compile Include="Pages\Lock\BaseLockPage.cs" />
<Compile Include="Pages\Lock\LockPasswordPage.cs" />
<Compile Include="Pages\TwoFactorMethodsPage.cs" />
<Compile Include="Pages\LoginTwoFactorPage.cs" />
<Compile Include="Pages\PasswordHintPage.cs" />
<Compile Include="Pages\RegisterPage.cs" />

View file

@ -27,11 +27,13 @@ namespace Bit.App.Pages
private readonly SymmetricCryptoKey _key;
private readonly Dictionary<TwoFactorProviderType, Dictionary<string, object>> _providers;
private readonly TwoFactorProviderType? _providerType;
private readonly FullLoginResult _result;
public LoginTwoFactorPage(string email, FullLoginResult result, TwoFactorProviderType? type = null)
: base(updateActivity: false)
{
_email = email;
_result = result;
_masterPasswordHash = result.MasterPasswordHash;
_key = result.Key;
_providers = result.TwoFactorProviders;
@ -128,7 +130,7 @@ namespace Bit.App.Pages
Text = "Use another two-step login method",
Style = (Style)Application.Current.Resources["btn-primaryAccent"],
Margin = new Thickness(15, 0, 15, 25),
Command = new Command(() => AnotherMethod()),
Command = new Command(() => AnotherMethodAsync()),
Uppercase = false,
BackgroundColor = Color.Transparent
};
@ -208,9 +210,9 @@ namespace Bit.App.Pages
}
}
private void AnotherMethod()
private async void AnotherMethodAsync()
{
await Navigation.PushForDeviceAsync(new TwoFactorMethodsPage(_email, _result));
}
private void SendEmail()

View file

@ -0,0 +1,141 @@
using System;
using Bit.App.Controls;
using Xamarin.Forms;
using Bit.App.Models;
namespace Bit.App.Pages
{
public class TwoFactorMethodsPage : ExtendedContentPage
{
private readonly string _email;
private readonly FullLoginResult _result;
public TwoFactorMethodsPage(string email, FullLoginResult result)
: base(updateActivity: false)
{
_email = email;
_result = result;
Init();
}
public ExtendedTextCell AuthenticatorCell { get; set; }
public ExtendedTextCell EmailCell { get; set; }
public ExtendedTextCell DuoCell { get; set; }
public ExtendedTextCell RecoveryCell { get; set; }
private void Init()
{
var section = new TableSection(" ");
if(_result.TwoFactorProviders.ContainsKey(Enums.TwoFactorProviderType.Authenticator))
{
AuthenticatorCell = new ExtendedTextCell
{
Text = "Authenticator App",
Detail = "Use an authenticator app (such as Authy or Google Authenticator) to generate time-based verification codes."
};
section.Add(AuthenticatorCell);
}
if(_result.TwoFactorProviders.ContainsKey(Enums.TwoFactorProviderType.Duo))
{
DuoCell = new ExtendedTextCell
{
Text = "Duo",
Detail = "Use duo."
};
section.Add(DuoCell);
}
if(_result.TwoFactorProviders.ContainsKey(Enums.TwoFactorProviderType.Email))
{
EmailCell = new ExtendedTextCell
{
Text = "Email",
Detail = "Verification codes will be emailed to you."
};
section.Add(EmailCell);
}
RecoveryCell = new ExtendedTextCell
{
Text = "Recovery Code",
Detail = "Lost access to all of your two-factor providers? Use your recovery code to disable all two-factor providers from your account."
};
section.Add(RecoveryCell);
var table = new ExtendedTableView
{
EnableScrolling = true,
Intent = TableIntent.Settings,
HasUnevenRows = true,
Root = new TableRoot
{
section
}
};
if(Device.RuntimePlatform == Device.iOS)
{
table.RowHeight = -1;
table.EstimatedRowHeight = 100;
}
Title = "Two-step Login Options";
Content = table;
}
protected override void OnAppearing()
{
base.OnAppearing();
if(AuthenticatorCell != null)
{
AuthenticatorCell.Tapped += AuthenticatorCell_Tapped;
}
if(DuoCell != null)
{
DuoCell.Tapped += DuoCell_Tapped;
}
if(EmailCell != null)
{
EmailCell.Tapped += EmailCell_Tapped;
}
RecoveryCell.Tapped += RecoveryCell_Tapped;
}
protected override void OnDisappearing()
{
base.OnDisappearing();
if(AuthenticatorCell != null)
{
AuthenticatorCell.Tapped -= AuthenticatorCell_Tapped;
}
if(DuoCell != null)
{
DuoCell.Tapped -= DuoCell_Tapped;
}
if(EmailCell != null)
{
EmailCell.Tapped -= EmailCell_Tapped;
}
RecoveryCell.Tapped -= RecoveryCell_Tapped;
}
private void AuthenticatorCell_Tapped(object sender, EventArgs e)
{
}
private void RecoveryCell_Tapped(object sender, EventArgs e)
{
}
private void EmailCell_Tapped(object sender, EventArgs e)
{
}
private void DuoCell_Tapped(object sender, EventArgs e)
{
}
}
}