mirror of
https://github.com/bitwarden/mobile
synced 2025-12-18 01:03:24 +00:00
[Reset Password v1] Update Temp Password (#1492)
* [Reset Password v1] Update Temp Password * fixed order of operations for reset temp password flow * Refactored bool with auth result * Finished removal of temp password flow from set password * iOS extension support plus extension bugfixes Co-authored-by: addison <addisonbeck1@gmail.com> Co-authored-by: Matt Portune <mportune@bitwarden.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AuthenticationServices;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
@@ -431,6 +432,22 @@ namespace Bit.iOS.Extension
|
||||
return userService.IsAuthenticatedAsync();
|
||||
}
|
||||
|
||||
private void LogoutIfAuthed()
|
||||
{
|
||||
NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
if (await IsAuthed())
|
||||
{
|
||||
await AppHelpers.LogOutAsync();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
if (deviceActionService.SystemMajorVersion() >= 12)
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void LaunchHomePage()
|
||||
{
|
||||
var homePage = new HomePage();
|
||||
@@ -450,6 +467,8 @@ namespace Bit.iOS.Extension
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
|
||||
LogoutIfAuthed();
|
||||
}
|
||||
|
||||
private void LaunchEnvironmentFlow()
|
||||
@@ -497,6 +516,7 @@ namespace Bit.iOS.Extension
|
||||
if (loginPage.BindingContext is LoginPageViewModel vm)
|
||||
{
|
||||
vm.StartTwoFactorAction = () => DismissViewController(false, () => LaunchTwoFactorFlow(false));
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
vm.LogInSuccessAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => CompleteRequest(null, null);
|
||||
}
|
||||
@@ -505,6 +525,8 @@ namespace Bit.iOS.Extension
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
|
||||
LogoutIfAuthed();
|
||||
}
|
||||
|
||||
private void LaunchLoginSsoFlow()
|
||||
@@ -517,6 +539,7 @@ namespace Bit.iOS.Extension
|
||||
{
|
||||
vm.StartTwoFactorAction = () => DismissViewController(false, () => LaunchTwoFactorFlow(true));
|
||||
vm.StartSetPasswordAction = () => DismissViewController(false, () => LaunchSetPasswordFlow());
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
vm.SsoAuthSuccessAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
@@ -525,6 +548,8 @@ namespace Bit.iOS.Extension
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
|
||||
LogoutIfAuthed();
|
||||
}
|
||||
|
||||
private void LaunchTwoFactorFlow(bool authingWithSso)
|
||||
@@ -545,6 +570,7 @@ namespace Bit.iOS.Extension
|
||||
{
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchLoginFlow());
|
||||
}
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
}
|
||||
|
||||
var navigationPage = new NavigationPage(twoFactorPage);
|
||||
@@ -561,6 +587,7 @@ namespace Bit.iOS.Extension
|
||||
ThemeManager.ApplyResourcesToPage(setPasswordPage);
|
||||
if (setPasswordPage.BindingContext is SetPasswordPageViewModel vm)
|
||||
{
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
vm.SetPasswordSuccessAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
@@ -570,5 +597,23 @@ namespace Bit.iOS.Extension
|
||||
setPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(setPasswordController, true, null);
|
||||
}
|
||||
|
||||
private void LaunchUpdateTempPasswordFlow()
|
||||
{
|
||||
var updateTempPasswordPage = new UpdateTempPasswordPage();
|
||||
var app = new App.App(new AppOptions { IosExtension = true });
|
||||
ThemeManager.SetTheme(false, app.Resources);
|
||||
ThemeManager.ApplyResourcesToPage(updateTempPasswordPage);
|
||||
if (updateTempPasswordPage.BindingContext is UpdateTempPasswordPageViewModel vm)
|
||||
{
|
||||
vm.UpdateTempPasswordSuccessAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
vm.LogOutAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
|
||||
var navigationPage = new NavigationPage(updateTempPasswordPage);
|
||||
var updateTempPasswordController = navigationPage.CreateViewController();
|
||||
updateTempPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(updateTempPasswordController, true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user