From c59549f25a5d4c8253e87a39f18733efc219b066 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 30 Jul 2016 13:28:13 -0400 Subject: [PATCH] Added remember last email login. adjsuted sizing on extension slider. Added fallback logout to fingerprint. --- src/App/Constants.cs | 1 + src/App/Pages/Lock/LockFingerprintPage.cs | 4 ++++ src/App/Pages/LoginPage.cs | 20 +++++++++++++++++++- src/App/Pages/Settings/SettingsPage.cs | 6 ++++-- src/iOS.Core/Views/SliderTableViewCell.cs | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/App/Constants.cs b/src/App/Constants.cs index 855803df8..8a90bcdc7 100644 --- a/src/App/Constants.cs +++ b/src/App/Constants.cs @@ -7,6 +7,7 @@ public const string SettingLockSeconds = "setting:lockSeconds"; public const string SettingLastBackgroundedDate = "lastBackgroundedDate"; public const string SettingLocked = "locked"; + public const string SettingLastLoginEmail = "lastLoginEmail"; public const string PasswordGeneratorLength = "pwGenerator:length"; public const string PasswordGeneratorUppercase = "pwGenerator:uppercase"; diff --git a/src/App/Pages/Lock/LockFingerprintPage.cs b/src/App/Pages/Lock/LockFingerprintPage.cs index 91f265957..6773bba46 100644 --- a/src/App/Pages/Lock/LockFingerprintPage.cs +++ b/src/App/Pages/Lock/LockFingerprintPage.cs @@ -100,6 +100,10 @@ namespace Bit.App.Pages _settings.AddOrUpdateValue(Constants.SettingLocked, false); await Navigation.PopModalAsync(); } + else if(result.Status == FingerprintAuthenticationResultStatus.FallbackRequested) + { + MessagingCenter.Send(Application.Current, "Logout", (string)null); + } } } } diff --git a/src/App/Pages/LoginPage.cs b/src/App/Pages/LoginPage.cs index 82556f396..0f014779c 100644 --- a/src/App/Pages/LoginPage.cs +++ b/src/App/Pages/LoginPage.cs @@ -9,6 +9,7 @@ using Xamarin.Forms; using XLabs.Ioc; using Acr.UserDialogs; using System.Threading.Tasks; +using Plugin.Settings.Abstractions; namespace Bit.App.Pages { @@ -20,6 +21,7 @@ namespace Bit.App.Pages private IAppIdService _appIdService; private IUserDialogs _userDialogs; private ISyncService _syncService; + private ISettings _settings; public LoginPage() { @@ -29,6 +31,7 @@ namespace Bit.App.Pages _appIdService = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); _syncService = Resolver.Resolve(); + _settings = Resolver.Resolve(); Init(); } @@ -48,6 +51,12 @@ namespace Bit.App.Pages entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope", containerPadding: padding); + var lastLoginEmail = _settings.GetValueOrDefault(Constants.SettingLastLoginEmail); + if(!string.IsNullOrWhiteSpace(lastLoginEmail)) + { + EmailCell.Entry.Text = lastLoginEmail; + } + PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.Completed += Entry_Completed; @@ -110,7 +119,15 @@ namespace Bit.App.Pages { base.OnAppearing(); MessagingCenter.Send(Application.Current, "ShowStatusBar", true); - EmailCell.Entry.Focus(); + + if(!string.IsNullOrWhiteSpace(EmailCell.Entry.Text)) + { + PasswordCell.Entry.Focus(); + } + else + { + EmailCell.Entry.Focus(); + } } private async void Entry_Completed(object sender, EventArgs e) @@ -160,6 +177,7 @@ namespace Bit.App.Pages _authService.Token = response.Result.Token; _authService.UserId = response.Result?.Profile?.Id; _authService.Email = response.Result?.Profile?.Email; + _settings.AddOrUpdateValue(Constants.SettingLastLoginEmail, _authService.Email); if(_authService.IsAuthenticatedTwoFactor) { diff --git a/src/App/Pages/Settings/SettingsPage.cs b/src/App/Pages/Settings/SettingsPage.cs index ea10623e3..73aa4f118 100644 --- a/src/App/Pages/Settings/SettingsPage.cs +++ b/src/App/Pages/Settings/SettingsPage.cs @@ -316,13 +316,14 @@ namespace Bit.App.Pages return; } - if(cell.On) + if(cell.On && !_settings.GetValueOrDefault(Constants.SettingPinUnlockOn, false)) { + cell.On = false; var pinPage = new SettingsPinPage(); pinPage.OnPinEntered += PinEntered; Navigation.PushAsync(pinPage); } - else + else if(!cell.On) { _settings.AddOrUpdateValue(Constants.SettingPinUnlockOn, false); } @@ -337,6 +338,7 @@ namespace Bit.App.Pages _settings.AddOrUpdateValue(Constants.SettingPinUnlockOn, true); _settings.AddOrUpdateValue(Constants.SettingFingerprintUnlockOn, false); + PinCell.On = true; FingerprintCell.On = false; } diff --git a/src/iOS.Core/Views/SliderTableViewCell.cs b/src/iOS.Core/Views/SliderTableViewCell.cs index e8158fb2f..30231d2dd 100644 --- a/src/iOS.Core/Views/SliderTableViewCell.cs +++ b/src/iOS.Core/Views/SliderTableViewCell.cs @@ -19,7 +19,7 @@ namespace Bit.iOS.Core.Views MinValue = min, MaxValue = max, TintColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f), - Frame = new CoreGraphics.CGRect(0, 0, 180, 20) + Frame = new CoreGraphics.CGRect(0, 0, 180, 30) }; Slider.ValueChanged += Slider_ValueChanged; Value = value;