1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-18 15:37:42 +01:00

touch ups on two-factor page

This commit is contained in:
Kyle Spearrin 2019-05-28 09:04:20 -04:00
parent bf4f0bdba0
commit 29ab7f7a30
6 changed files with 46 additions and 15 deletions

View File

@ -7,6 +7,7 @@ using AWebkit = Android.Webkit;
using Java.Interop; using Java.Interop;
using Android.Content; using Android.Content;
using Bit.Droid.Renderers; using Bit.Droid.Renderers;
using System.ComponentModel;
[assembly: ExportRenderer(typeof(HybridWebView), typeof(HybridWebViewRenderer))] [assembly: ExportRenderer(typeof(HybridWebView), typeof(HybridWebViewRenderer))]
namespace Bit.Droid.Renderers namespace Bit.Droid.Renderers
@ -47,6 +48,15 @@ namespace Bit.Droid.Renderers
} }
} }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if(e.PropertyName == HybridWebView.UriProperty.PropertyName)
{
Control.LoadUrl(Element.Uri);
}
}
public class JSBridge : Java.Lang.Object public class JSBridge : Java.Lang.Object
{ {
private readonly WeakReference<HybridWebViewRenderer> _hybridWebViewRenderer; private readonly WeakReference<HybridWebViewRenderer> _hybridWebViewRenderer;

View File

@ -89,7 +89,6 @@ namespace Bit.App.Pages
{ {
await _deviceActionService.ShowLoadingAsync(AppResources.LoggingIn); await _deviceActionService.ShowLoadingAsync(AppResources.LoggingIn);
var response = await _authService.LogInAsync(Email, MasterPassword); var response = await _authService.LogInAsync(Email, MasterPassword);
await _deviceActionService.HideLoadingAsync();
if(RememberEmail) if(RememberEmail)
{ {
await _storageService.SaveAsync(Keys_RememberedEmail, Email); await _storageService.SaveAsync(Keys_RememberedEmail, Email);
@ -98,6 +97,7 @@ namespace Bit.App.Pages
{ {
await _storageService.RemoveAsync(Keys_RememberedEmail); await _storageService.RemoveAsync(Keys_RememberedEmail);
} }
await _deviceActionService.HideLoadingAsync();
if(response.TwoFactor) if(response.TwoFactor)
{ {
var page = new TwoFactorPage(); var page = new TwoFactorPage();

View File

@ -24,12 +24,12 @@
<ToolbarItem Text="{u:I18n Continue}" Clicked="Continue_Clicked" x:Name="_continueItem" /> <ToolbarItem Text="{u:I18n Continue}" Clicked="Continue_Clicked" x:Name="_continueItem" />
</ContentPage.ToolbarItems> </ContentPage.ToolbarItems>
<ScrollView> <ScrollView x:Name="_scrollView">
<StackLayout Spacing="0" Padding="0"> <StackLayout Spacing="10" Padding="0, 0, 0, 10" VerticalOptions="FillAndExpand">
<StackLayout Spacing="0" Padding="0" IsVisible="{Binding TotpMethod, Mode=OneWay}"> <StackLayout Spacing="20" Padding="0" IsVisible="{Binding TotpMethod, Mode=OneWay}">
<Label <Label
Text="{Binding TotpInstruction, Mode=OneWay}" Text="{Binding TotpInstruction, Mode=OneWay}"
Margin="20, 0" Margin="10, 20, 10, 0"
HorizontalTextAlignment="Center" /> HorizontalTextAlignment="Center" />
<StackLayout StyleClass="box"> <StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-input"> <StackLayout StyleClass="box-row, box-row-input">
@ -53,14 +53,14 @@
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
<StackLayout Spacing="0" Padding="0" IsVisible="{Binding YubikeyMethod, Mode=OneWay}"> <StackLayout Spacing="20" Padding="0" IsVisible="{Binding YubikeyMethod, Mode=OneWay}">
<Label <Label
Text="{Binding YubikeyInstruction, Mode=OneWay}" Text="{Binding YubikeyInstruction, Mode=OneWay}"
Margin="20, 0" Margin="10, 20, 10, 0"
HorizontalTextAlignment="Center" /> HorizontalTextAlignment="Center" />
<Image <Image
Source="yubikey.png" Source="yubikey.png"
Margin="20, 0" Margin="10, 0"
WidthRequest="266" WidthRequest="266"
HeightRequest="160" HeightRequest="160"
HorizontalOptions="Center" /> HorizontalOptions="Center" />
@ -82,13 +82,14 @@
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
<StackLayout Spacing="0" Padding="0" IsVisible="{Binding DuoMethod, Mode=OneWay}"> <StackLayout Spacing="0" Padding="0" IsVisible="{Binding DuoMethod, Mode=OneWay}"
VerticalOptions="FillAndExpand">
<controls:HybridWebView <controls:HybridWebView
x:Name="_duoWebView" x:Name="_duoWebView"
HorizontalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
MinimumHeightRequest="400" /> MinimumHeightRequest="400" />
<StackLayout StyleClass="box"> <StackLayout StyleClass="box" VerticalOptions="End">
<StackLayout StyleClass="box-row, box-row-switch"> <StackLayout StyleClass="box-row, box-row-switch">
<Label <Label
Text="{u:I18n RememberMe}" Text="{u:I18n RememberMe}"
@ -107,11 +108,12 @@
IsVisible="{Binding SelectedProviderType, Mode=OneWay, Converter={StaticResource isNull}}"> IsVisible="{Binding SelectedProviderType, Mode=OneWay, Converter={StaticResource isNull}}">
<Label <Label
Text="{u:I18n NoTwoStepAvailable}" Text="{u:I18n NoTwoStepAvailable}"
Margin="20, 0" Margin="10, 20, 10, 0"
HorizontalTextAlignment="Center" /> HorizontalTextAlignment="Center" />
</StackLayout> </StackLayout>
<Button Text="{u:I18n UseAnotherTwoStepMethod}" <Button Text="{u:I18n UseAnotherTwoStepMethod}"
Clicked="Methods_Clicked"></Button> Clicked="Methods_Clicked"
Margin="10, 0"></Button>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>

View File

@ -1,5 +1,6 @@
using Bit.App.Controls; using Bit.App.Controls;
using System; using System;
using System.Threading.Tasks;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -13,14 +14,19 @@ namespace Bit.App.Pages
_vm = BindingContext as TwoFactorPageViewModel; _vm = BindingContext as TwoFactorPageViewModel;
_vm.Page = this; _vm.Page = this;
DuoWebView = _duoWebView; DuoWebView = _duoWebView;
SetActivityIndicator();
} }
public HybridWebView DuoWebView { get; set; } public HybridWebView DuoWebView { get; set; }
protected override void OnAppearing() protected async override void OnAppearing()
{ {
base.OnAppearing(); base.OnAppearing();
_vm.Init(); await LoadOnAppearedAsync(_scrollView, true, () =>
{
_vm.Init();
return Task.FromResult(0);
});
} }
private async void Continue_Clicked(object sender, EventArgs e) private async void Continue_Clicked(object sender, EventArgs e)

View File

@ -36,6 +36,8 @@ namespace Bit.App.Pages
_apiService = ServiceContainer.Resolve<IApiService>("apiService"); _apiService = ServiceContainer.Resolve<IApiService>("apiService");
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService"); _platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
_environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService"); _environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
PageTitle = AppResources.TwoStepLogin;
} }
public string TwoFactorEmail public string TwoFactorEmail
@ -48,7 +50,8 @@ namespace Bit.App.Pages
public string Token { get; set; } public string Token { get; set; }
public bool DuoMethod => SelectedProviderType == TwoFactorProviderType.Email; public bool DuoMethod => SelectedProviderType == TwoFactorProviderType.Duo ||
SelectedProviderType == TwoFactorProviderType.OrganizationDuo;
public bool YubikeyMethod => SelectedProviderType == TwoFactorProviderType.YubiKey; public bool YubikeyMethod => SelectedProviderType == TwoFactorProviderType.YubiKey;

View File

@ -4,6 +4,7 @@ using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS; using Xamarin.Forms.Platform.iOS;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.iOS.Renderers; using Bit.iOS.Renderers;
using System.ComponentModel;
[assembly: ExportRenderer(typeof(HybridWebView), typeof(HybridWebViewRenderer))] [assembly: ExportRenderer(typeof(HybridWebView), typeof(HybridWebViewRenderer))]
namespace Bit.iOS.Renderers namespace Bit.iOS.Renderers
@ -43,6 +44,15 @@ namespace Bit.iOS.Renderers
} }
} }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if(e.PropertyName == HybridWebView.UriProperty.PropertyName)
{
Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Uri)));
}
}
public void DidReceiveScriptMessage(WKUserContentController userContentController, WKScriptMessage message) public void DidReceiveScriptMessage(WKUserContentController userContentController, WKScriptMessage message)
{ {
Element.InvokeAction(message.Body.ToString()); Element.InvokeAction(message.Body.ToString());