diff --git a/src/App/App.csproj b/src/App/App.csproj index 118b1b7ee..ec5e3981b 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -134,6 +134,7 @@ + diff --git a/src/App/Pages/LoginTwoFactorPage.cs b/src/App/Pages/LoginTwoFactorPage.cs index 2b1c3207b..7175560f5 100644 --- a/src/App/Pages/LoginTwoFactorPage.cs +++ b/src/App/Pages/LoginTwoFactorPage.cs @@ -27,11 +27,13 @@ namespace Bit.App.Pages private readonly SymmetricCryptoKey _key; private readonly Dictionary> _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() diff --git a/src/App/Pages/TwoFactorMethodsPage.cs b/src/App/Pages/TwoFactorMethodsPage.cs new file mode 100644 index 000000000..a46c0090a --- /dev/null +++ b/src/App/Pages/TwoFactorMethodsPage.cs @@ -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) + { + } + } +}